Skip field level violations on the book outline form
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3212249. --> Reported by: [cestmoi](https://www.drupal.org/user/112679) Related to !2833 !100 !99 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The presence of any field level violations causes the Book outline form to throw a fatal error on form submissions because the field can't be accessed on the form.</p> <hr> <p>On drupal 9.1.4, production.</p> <p>The following error happened on trying to update certain node outline. I couldn't reproduce it on the other nodes in the same book outline.</p> <blockquote><p>TypeError: Argument 2 passed to Drupal\Component\Utility\NestedArray::getValue() must be of the type array, null given, called in /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Field/WidgetBase.php on line 414 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Component/Utility/NestedArray.php)</p> <p>#0 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Field/WidgetBase.php(414): Drupal\Component\Utility\NestedArray::getValue(Array, NULL)<br> #1 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(265): Drupal\Core\Field\WidgetBase-&gt;flagErrors(Object(Drupal\Core\Field\EntityReferenceFieldItemList), Object(Symfony\Component\Validator\ConstraintViolationList), Array, Object(Drupal\Core\Form\FormState))<br> #2 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(268): Drupal\Core\Entity\Entity\EntityFormDisplay-&gt;flagWidgetsErrorsFromViolations(Object(Drupal\Core\Entity\EntityConstraintViolationList), Array, Object(Drupal\Core\Form\FormState))<br> #3 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(214): Drupal\Core\Entity\ContentEntityForm-&gt;flagViolations(Object(Drupal\Core\Entity\EntityConstraintViolationList), Array, Object(Drupal\Core\Form\FormState))<br> #4 [internal function]: Drupal\Core\Entity\ContentEntityForm-&gt;validateForm(Array, Object(Drupal\Core\Form\FormState))<br> #5 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)<br> #6 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormValidator.php(273): Drupal\Core\Form\FormValidator-&gt;executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))<br> #7 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator-&gt;doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'node_book_book_...')<br> #8 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormBuilder.php(589): Drupal\Core\Form\FormValidator-&gt;validateForm('node_book_book_...', Array, Object(Drupal\Core\Form\FormState))<br> #9 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder-&gt;processForm('node_book_book_...', Array, Object(Drupal\Core\Form\FormState))<br> #10 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder-&gt;buildForm(Object(Drupal\book\Form\BookOutlineForm), Object(Drupal\Core\Form\FormState))<br> #11 [internal function]: Drupal\Core\Controller\FormController-&gt;getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))<br> #12 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)<br> #13 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}()<br> #14 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))<br> #15 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array)<br> #16 /home4/usrname/drupalsite.tld/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}()<br> #17 /home4/usrname/drupalsite.tld/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)<br> #18 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #19 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #20 /home4/usrname/drupalsite.tld/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #21 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #22 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #23 /home4/usrname/drupalsite.tld/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #24 /home4/usrname/drupalsite.tld/web/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br> #25 /home4/usrname/drupalsite.tld/web/index.php(19): Drupal\Core\DrupalKernel-&gt;handle(Object(Symfony\Component\HttpFoundation\Request))<br> #26 {main} </p></blockquote> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>1. Went to update book outline of certain node/123 clicking on the Outline tab. /node/123/outline<br> 2. node weight was 0. Changed to 15<br> 3. click "Update Book Outline" &gt; the above error.</p> <p>I cleared cache and tried again. No fix.<br> I tried changing the weight to other numbers. No fix.<br> I tested other nodes under same book and all was good with them!<br> I couldn't find anything different with the problematic node ! all nodes in the outline are same content type. </p> <p>I went in DB (phpMyAdmin on shared host) and edited the node weight from 0 to 15 and saved. </p> <p> UPDATE `book` SET `weight` = '15' WHERE `book`.`nid` = 123; </p> <p>I tried updating again via UI and all went fine this time ! I edited it back to 0 and saved (in UI) ; I then updated it again from 0 to 15 and all went well !</p> <p>I tried to reproduce it after undoing the DB fix:</p> <p>I went again to DB and edited it back to 0:</p> <p> UPDATE `book` SET `weight` = '0' WHERE `book`.`nid` = 123 </p> <p>Tested again doing it from UI and all went fine.</p> > Related issue: [Issue #3167146](https://www.drupal.org/node/3167146)
issue