- Issue created by @geek-merlin
- Status changed to Needs review
5 months ago 2:40pm 28 August 2024 - π©πͺGermany geek-merlin Freiburg, Germany
Added a trivial fix that covers the case when
$elements['widget']['add_more']
is empty.Applies cleanly on my composer site and fixes the issue for me.
- Status changed to RTBC
5 months ago 3:05pm 28 August 2024 - π©πͺGermany anruether Bonn
As for the Steps to reproduce
I have a field config that includes:settings: handler: paragraphs_limits handler_settings: target_bundles: h4d_commerce_house: h4d_commerce_house h4d_commerce_consumer: h4d_commerce_consumer h4d_commerce_business: h4d_commerce_business negate: 0 target_bundles_drag_drop: h4d_commerce_house: weight: 0 enabled: true lower_limit: 0 upper_limit: 1 h4d_commerce_consumer: weight: 1 enabled: true lower_limit: 0 upper_limit: 1 h4d_commerce_business: weight: 2 enabled: true lower_limit: 0 upper_limit: 1
When creating/editing content, I clicked to add a paragraph (button widget), but the form won't show. Instead I get a warning and an error. The patch fixes this for me.
Warning: Undefined array key "add_more" in _paragraphs_limits_disallow_limited_paragraphs() (line 90 of /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module) #0 /home/andi/git/site-h4d-greenopolis/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real() #1 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module(90): _drupal_error_handler() #2 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module(45): _paragraphs_limits_disallow_limited_paragraphs() #3 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): paragraphs_limits_field_widget_complete_paragraphs_form_alter() #4 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/hux/src/HuxModuleHandler.php(163): Drupal\Core\Extension\ModuleHandler->alter() #5 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Field/WidgetBase.php(156): Drupal\hux\HuxModuleHandler->alter() #6 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php(1503): Drupal\Core\Field\WidgetBase->form() #7 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(190): Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->form() #8 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(121): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() #9 /home/andi/git/site-h4d-greenopolis/web/core/modules/node/src/NodeForm.php(134): Drupal\Core\Entity\ContentEntityForm->form() #10 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\node\NodeForm->form() #11 [internal function]: Drupal\Core\Entity\EntityForm->buildForm() #12 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array() #13 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm() #14 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm() #15 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm() #16 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm() #17 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/group/src/Entity/Controller/GroupRelationshipController.php(391): Drupal\Core\Entity\EntityFormBuilder->getForm() #18 /home/andi/git/site-h4d-greenopolis/web/modules/custom/route_controller/src/WrapExistingRoute/WrapExistingRouteController.php(96): Drupal\group\Entity\Controller\GroupRelationshipController->createForm() #19 /home/andi/git/site-h4d-greenopolis/web/modules/custom/h4d_entity_logic/src/RouteDecorator/GroupOnlyOneRouteControllerDecorator.php(66): Drupal\route_controller\WrapExistingRoute\WrapExistingRouteController->build() #20 [internal function]: Drupal\h4d_entity_logic\RouteDecorator\GroupOnlyOneRouteControllerDecorator->build() #21 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #22 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #23 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext() #24 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #25 /home/andi/git/site-h4d-greenopolis/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #26 /home/andi/git/site-h4d-greenopolis/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #27 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle() #28 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #29 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #30 /home/andi/git/site-h4d-greenopolis/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle() #31 /home/andi/git/site-h4d-greenopolis/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #32 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #33 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #34 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #35 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #36 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #37 /home/andi/git/site-h4d-greenopolis/web/index.php(19): Drupal\Core\DrupalKernel->handle() #38 /home/andi/git/site-h4d-greenopolis/vendor/drush/drush/misc/d8-rs-router.php(48): require('...') #39 {main}
TypeError: _paragraphs_limits_add_more_is_empty(): Argument #1 ($element) must be of type array, null given, called in /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module on line 90 in _paragraphs_limits_add_more_is_empty() (line 105 of /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module). Severity Error Hostname 127.0.0.1 Operations Backtrace #0 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module(90): _paragraphs_limits_add_more_is_empty() #1 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs_limits/paragraphs_limits.module(45): _paragraphs_limits_disallow_limited_paragraphs() #2 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): paragraphs_limits_field_widget_complete_paragraphs_form_alter() #3 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/hux/src/HuxModuleHandler.php(163): Drupal\Core\Extension\ModuleHandler->alter() #4 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Field/WidgetBase.php(156): Drupal\hux\HuxModuleHandler->alter() #5 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php(1503): Drupal\Core\Field\WidgetBase->form() #6 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php(190): Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->form() #7 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php(121): Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() #8 /home/andi/git/site-h4d-greenopolis/web/core/modules/node/src/NodeForm.php(134): Drupal\Core\Entity\ContentEntityForm->form() #9 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\node\NodeForm->form() #10 [internal function]: Drupal\Core\Entity\EntityForm->buildForm() #11 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array() #12 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm() #13 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm() #14 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm() #15 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm() #16 /home/andi/git/site-h4d-greenopolis/web/modules/contrib/group/src/Entity/Controller/GroupRelationshipController.php(391): Drupal\Core\Entity\EntityFormBuilder->getForm() #17 /home/andi/git/site-h4d-greenopolis/web/modules/custom/route_controller/src/WrapExistingRoute/WrapExistingRouteController.php(96): Drupal\group\Entity\Controller\GroupRelationshipController->createForm() #18 /home/andi/git/site-h4d-greenopolis/web/modules/custom/h4d_entity_logic/src/RouteDecorator/GroupOnlyOneRouteControllerDecorator.php(66): Drupal\route_controller\WrapExistingRoute\WrapExistingRouteController->build() #19 [internal function]: Drupal\h4d_entity_logic\RouteDecorator\GroupOnlyOneRouteControllerDecorator->build() #20 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #21 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #22 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext() #23 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #24 /home/andi/git/site-h4d-greenopolis/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #25 /home/andi/git/site-h4d-greenopolis/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #26 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle() #27 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #28 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #29 /home/andi/git/site-h4d-greenopolis/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle() #30 /home/andi/git/site-h4d-greenopolis/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #31 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #32 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #33 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #34 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #35 /home/andi/git/site-h4d-greenopolis/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #36 /home/andi/git/site-h4d-greenopolis/web/index.php(19): Drupal\Core\DrupalKernel->handle() #37 /home/andi/git/site-h4d-greenopolis/vendor/drush/drush/misc/d8-rs-router.php(48): require('...') #38 {main}
- Status changed to Needs work
5 months ago 5:34pm 29 August 2024 - π¨π¦Canada pavlosdan
So the issue seems to be happening when the field is limited by core's field storage setting "Allowed number of values". If this is set to unlimited the pages are working as intended. If this is limited at the storage level, Drupal removes the add more button completely from the form and paragraphs_limits breaks.
Would be nice to have a test for this.
- π¨π¦Canada pavlosdan
Admittedly setting a limit at the storage level was not something I thought about since I thought we'd be setting granular limits using the handler. Good catch!
Is it fair to assume that you weren't using the patch from β¨ This module should disallow adding more than the allowed amount of paragraph items in the add widget Fixed prior to rc2?
- π©πͺGermany anruether Bonn
@pavlosdan Thanks for your reply! That's correct ;)
Indeed, when setting field storage to unlimited this issue does not come up. I can see edge cases that might want to use limited storage, but we don't have them atm.
- First commit to issue fork.
- Status changed to Needs review
4 months ago 6:42pm 9 September 2024 - Status changed to Fixed
4 months ago 11:27pm 9 September 2024 -
pavlosdan β
committed d3a905e7 on 8.x-1.x authored by
geek-merlin β
Issue #3470739 by seanpclark, geek-merlin, anruether, pavlosdan: Setting...
-
pavlosdan β
committed d3a905e7 on 8.x-1.x authored by
geek-merlin β
Automatically closed - issue fixed for 2 weeks with no activity.