When we use entity browser widget to any field on node form and we click on Add New or Add Existing button and title is left empty, it gives following error:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Database\InvalidQueryException</em>: Query condition &#039;node_field_data.title IN ()&#039; cannot be empty. in <em class="placeholder">Drupal\Core\Database\Query\Condition-&gt;condition()</em> (line <em class="placeholder">103</em> of <em class="placeholder">core/lib/Drupal/Core/Database/Query/Condition.php</em>). <pre class="backtrace">Drupal\Core\Database\Query\Select-&gt;condition(&#039;node_field_data.title&#039;, Array, &#039;IN&#039;) (Line: 61)
Drupal\Core\Entity\Query\Sql\Condition-&gt;compile(Object) (Line: 163)
Drupal\Core\Entity\Query\Sql\Query-&gt;compile() (Line: 74)
Drupal\Core\Entity\Query\Sql\Query-&gt;execute() (Line: 504)
Drupal\Core\Entity\EntityStorageBase-&gt;loadByProperties(Array) (Line: 81)
Drupal\node_title_validation\Plugin\Validation\Constraint\NodeTitleConstraintValidator-&gt;validate(Object, Object) (Line: 185)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator-&gt;validateConstraints(Object, &#039;0000000027f7ef81000000005e48fe41&#039;, Array) (Line: 140)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator-&gt;validateNode(Object) (Line: 147)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator-&gt;validateNode(Object, Array, 1) (Line: 99)
Drupal\Core\TypedData\Validation\RecursiveContextualValidator-&gt;validate(Object, NULL, NULL) (Line: 90)
Drupal\Core\TypedData\Validation\RecursiveValidator-&gt;validate(Object) (Line: 135)
Drupal\Core\TypedData\TypedData-&gt;validate() (Line: 482)
Drupal\Core\Entity\ContentEntityBase-&gt;validate() (Line: 189)
Drupal\Core\Entity\ContentEntityForm-&gt;validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 83)
Drupal\Core\Form\FormValidator-&gt;executeValidateHandlers(Array, Object) (Line: 276)
Drupal\Core\Form\FormValidator-&gt;doValidateForm(Array, Object, &#039;node_agency_edit_form&#039;) (Line: 119)
Drupal\Core\Form\FormValidator-&gt;validateForm(&#039;node_agency_edit_form&#039;, Array, Object) (Line: 575)
Drupal\Core\Form\FormBuilder-&gt;processForm(&#039;node_agency_edit_form&#039;, Array, Object) (Line: 318)
Drupal\Core\Form\FormBuilder-&gt;buildForm(&#039;node_agency_edit_form&#039;, Object) (Line: 74)
Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 54)
Drupal\jsonapi\StackMiddleware\FormatSetter-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 666)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)

Node Title Validation Error

Comments

visshu007 created an issue. See original summary.

vishalkhode’s picture

StatusFileSize
new5.9 KB

Created patch to fix this issue.

vishalkhode’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 3000552-2.patch, failed testing. View results

vishalkhode’s picture

StatusFileSize
new5.9 KB
krzysztof domański’s picture

Status: Needs work » Needs review
yrocq’s picture

Updated patch

yrocq’s picture

StatusFileSize
new694 bytes

Oops. Updated patch

cgomezg’s picture

Status: Needs review » Reviewed & tested by the community
umirtma’s picture

StatusFileSize
new693 bytes
yrocq’s picture

StatusFileSize
new700 bytes

Fix patch.

renrhaf’s picture

Status: Reviewed & tested by the community » Needs review
renrhaf’s picture

StatusFileSize
new3.79 KB

New patch with some improvements. The main issue which was an error displayed when no title is filled and some AJAX calls are done through the form (adding paragraphs, adding a field with multiple cardinality, entity browser, etc...) is fixed.

renrhaf’s picture

StatusFileSize
new6.43 KB

Fix patch for latest dev version.

Status: Needs review » Needs work

The last submitted patch, 14: node_title_validation-empty_title-3000552-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

renrhaf’s picture

Status: Needs work » Needs review
StatusFileSize
new6.79 KB

Fix coding standards.

Status: Needs review » Needs work

The last submitted patch, 16: node_title_validation-empty_title-3000552-16.patch, failed testing. View results

  • cgomezg committed a1c36c9 on 8.x-1.x authored by Renrhaf
    Issue #3000552 by Renrhaf, vishalkhode, yrocq, umirtma, Krzysztof...
renrhaf’s picture

Status: Needs work » Fixed
renrhaf’s picture

Assigned: vishalkhode » Unassigned
renrhaf’s picture

  • cgomezg committed 97c09fe on 8.x-1.x
    Issue #3000552 by Renrhaf, vishalkhode, yrocq, umirtma, Krzysztof...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.