First, I added field Number type (doesn't matter whether it's float, integer or float) with Required turned ON in any content type.
Then I added Date field with Unlimited value.
Click "Add another item", couldn't add another Date field.
According from console in Google Chrome dev tools, the error was in Ajax call that says:

↵An AJAX HTTP error occurred.↵HTTP Result Code: 200↵Debugging information follows.↵Path: /node/add/page?ajax_form=1↵StatusText: OK↵ResponseText:


But if I turned OFF the Required in the field Number, the problem's gone.

Comments

ardnet created an issue. See original summary.

mpdonadio’s picture

Status: Active » Postponed (maintainer needs more info)

Can't reproduce this. What browser and OS are you on? What is your admin theme? Is there any error listed in the Recent Log Messages or PHP error log?

ardnet’s picture

Hey mpdonadio, thanks for responding.

So apparently the issue also happen in my VPS with following specs:
* Ubuntu 16.04
* PHP Version 7.0.8

For Drupal specs:
* Drupal 8.2.4
* Admin theme: Seven

And here's what I saw from Apache error logs and Recent Log Messages:

TypeError:
Argument 1 passed to Drupal\\Core\\Form\\FormState::setError() must be of the type array, null given, called in /var/www/html/core/lib/Drupal/Core/Field/WidgetBase.php on line 441 in /var/www/html/core/lib/Drupal/Core/Form/FormState.php on line 1093
#0 /var/www/html/core/lib/Drupal/Core/Field/WidgetBase.php(441): Drupal\\Core\\Form\\FormState->setError(NULL, Object(Drupal\\Core\\StringTranslation\\TranslatableMarkup))\n
#1 /var/www/html/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))\n
#2 /var/www/html/core/lib/Drupal/Core/Entity/ContentEntityForm.php(157): Drupal\\Core\\Entity\\Entity\\EntityFormDisplay->flagWidgetsErrorsFromViolations(Object(Drupal\\Core\\Entity\\EntityConstraintViolationList), Array, Object(Drupal\\Core\\Form\\FormState))\n
#3 /var/www/html/core/lib/Drupal/Core/Entity/ContentEntityForm.php(103): Drupal\\Core\\Entity\\ContentEntityForm->flagViolations(Object(Drupal\\Core\\Entity\\EntityConstraintViolationList), Array, Object(Drupal\\Core\\Form\\FormState))\n
#4 [internal function]: Drupal\\Core\\Entity\\ContentEntityForm->validateForm(Array, Object(Drupal\\Core\\Form\\FormState))\n
#5 /var/www/html/core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array)\n
#6 /var/www/html/core/lib/Drupal/Core/Form/FormValidator.php(270): Drupal\\Core\\Form\\FormValidator->executeValidateHandlers(Array, Object(Drupal\\Core\\Form\\FormState))\n
#7 /var/www/html/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\\Core\\Form\\FormValidator->doValidateForm(Array, Object(Drupal\\Core\\Form\\FormState), 'node_host_form')\n
#8 /var/www/html/core/lib/Drupal/Core/Form/FormBuilder.php(571): Drupal\\Core\\Form\\FormValidator->validateForm('node_host_form', Array, Object(Drupal\\Core\\Form\\FormState))\n
#9 /var/www/html/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\\Core\\Form\\FormBuilder->processForm('node_host_form', Array, Object(Drupal\\Core\\Form\\FormState))\n
#10 /var/www/html/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\\Core\\Form\\FormBuilder->buildForm('node_host_form', Object(Drupal\\Core\\Form\\FormState))\n
#11 /var/www/html/core/modules/node/src/Controller/NodeController.php(113): Drupal\\Core\\Entity\\EntityFormBuilder->getForm(Object(Drupal\\node\\Entity\\Node))\n
#12 [internal function]: Drupal\\node\\Controller\\NodeController->add(Object(Drupal\\node\\Entity\\NodeType))\n
#13 /var/www/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)\n
#14 /var/www/html/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n
#15 /var/www/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer->executeInRenderContext(Object(Drupal\\Core\\Render\\RenderContext), Object(Closure))\n
#16 /var/www/html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)\n
#17 [internal function]: Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n
#18 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array)\n
#19 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n
#20 /var/www/html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#21 /var/www/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#22 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#23 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\\page_cache\\StackMiddleware\\PageCache->pass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#24 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#25 /var/www/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#26 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#27 /var/www/html/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n
#28 /var/www/html/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n
#29 {main}, referer: http://xxx.com/node/add/host


Let me know if there's any other info you need to know.
Thanks

ardnet’s picture

OK, I just Googled the errors, and it leads me to these issues:
* https://www.drupal.org/node/2648520
* https://www.drupal.org/node/2614250

Thoughts?

mpdonadio’s picture

Component: datetime.module » field system
Status: Postponed (maintainer needs more info) » Postponed
Parent issue: » #2027059: Improve the documentation of WidgetBase::errorElement() for mapping violation property paths to form elements
Related issues: +#2614250: Number widget validation can break AJAX actions

This def looks like it is caused directly by or related to #2027059: Improve the documentation of WidgetBase::errorElement() for mapping violation property paths to form elements. Based on the similar issues, I think we need to postpone on that first.

drugan’s picture

The possible solution is here:

#2816859: Allow the 'step' to be configured as a NumberWidget setting

It adds default minimum and maximum for integer and decimal fields and much more useful settings. The float field does not have such constraint by default but it silently truncates the field value to 14 digits precision as it said in PHP docs for the float number type.

As for your issue you could add default value for the required field which does not work now but the patch resolves this issue too.

amateescu’s picture