dpi / unlimited_number

Provides a widget for number fields for unlimited or limited values.
https://www.drupal.org/project/unlimited_number
GNU General Public License v2.0
0 stars 1 forks source link

Unlimited option gives fatal error when saving node #9

Open lennartvava opened 6 years ago

lennartvava commented 6 years ago

I placed some of the rng fields on the node form. When selecting the unlimited option on the node form (not on the event settings form), a fatal error is generated. On the event settings form everything works fine. Here's the error output:

Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given, called in .../web/core/lib/Drupal/Core/Field/WidgetBase.php on line 439 and defined in Drupal\Core\Form\FormState->setError() (regel 1093 van .../web/core/lib/Drupal/Core/Form/FormState.php) #0 .../web/core/includes/bootstrap.inc(566): _drupal_error_handler_real(4096, 'Argument 1 pass...', '/.../.../...', 1093, Array) #1 .../web/core/lib/Drupal/Core/Form/FormState.php(1093): _drupal_error_handler(4096, 'Argument 1 pass...', '/.../.../...', 1093, Array) #2 .../web/core/lib/Drupal/Core/Field/WidgetBase.php(439): Drupal\Core\Form\FormState->setError(NULL, Object(Drupal\Core\StringTranslation\TranslatableMarkup)) #3 .../web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(255): Drupal\Core\Field\WidgetBase->flagErrors(Object(Drupal\Core\Field\FieldItemList), Object(Symfony\Component\Validator\ConstraintViolationList), Array, Object(Drupal\Core\Form\FormState)) #4 .../web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(260): Drupal\Core\Entity\Entity\EntityFormDisplay->flagWidgetsErrorsFromViolations(Object(Drupal\Core\Entity\EntityConstraintViolationList), Array, Object(Drupal\Core\Form\FormState)) #5 .../web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(206): Drupal\Core\Entity\ContentEntityForm->flagViolations(Object(Drupal\Core\Entity\EntityConstraintViolationList), Array, Object(Drupal\Core\Form\FormState)) #6 [internal function]: Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object(Drupal\Core\Form\FormState)) #7 .../web/core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array) #8 .../web/core/lib/Drupal/Core/Form/FormValidator.php(274): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState)) #9 .../web/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'node_event_edit...') #10 .../web/core/lib/Drupal/Core/Form/FormBuilder.php(571): Drupal\Core\Form\FormValidator->validateForm('node_event_edit...', Array, Object(Drupal\Core\Form\FormState)) #11 .../web/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('node_event_edit...', Array, Object(Drupal\Core\Form\FormState)) #12 .../web/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeForm), Object(Drupal\Core\Form\FormState)) #13 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #14 .../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #15 .../web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #16 .../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #17 .../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #18 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #19 .../vendor/symfony/http-kernel/HttpKernel.php(153): call_user_func_array(Object(Closure), Array) #20 .../vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #21 .../web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 .../web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 .../web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 .../web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 .../web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 .../web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 .../vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 .../web/core/lib/Drupal/Core/DrupalKernel.php(657): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 .../web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #30 {main}.

nplowman commented 5 years ago

I was running into this as well and did some investigation and found the following: 1) The "min" field setting on number fields gets set to "1" by default. Since the "Unlimited" option on the field widget sets a value of "0". This results in a validation error when the form is submitted if the "unlimited" radio button is selected. 2) The $error_element variable in the WidgetBase.php method is getting set to null, which is causing the request to fail with a hard error instead of simply showing a validation error. I'm guessing the render array for the field widget is probably malformed in some way, but this will require deeper investigation.

For now though, I am successfully able to avoid the error by simply setting the 'min' setting on the Maximum Registrations field to 0.