I get an error when using Layouts with Drupal 9.4.
If I configure a paragraph type with a text field in it, and enable layout paragraphs for that type, when I place a paragraph in a node, I get this error.
When I disable layout paragraphs for the type, the paragraph works normally.
The website encountered an unexpected error. Please try again later.
RuntimeException: The subform and parent form must contain the #parents property, which must be an array. Try calling this method from a #process callback instead. in Drupal\Core\Form\SubformState->getParents() (line 76 of core/lib/Drupal/Core/Form/SubformState.php).
Drupal\Core\Form\SubformState->getValues() (Line: 26)
Drupal\Core\Form\SubformState->getValue('label') (Line: 126)
Drupal\Core\Layout\LayoutDefault->submitConfigurationForm(Array, Object) (Line: 178)
Drupal\layout_paragraphs\Plugin\paragraphs\Behavior\LayoutParagraphsBehavior->submitBehaviorForm(Object, Array, Object) (Line: 2312)
Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->massageFormValues(Array, Array, Object) (Line: 400)
Drupal\Core\Field\WidgetBase->extractFormValues(Object, Array, Object) (Line: 2381)
Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget->extractFormValues(Object, Array, Object) (Line: 235)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object, Array, Object) (Line: 334)
Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 293)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 155)
Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object) (Line: 186)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'node_article_edit_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('node_article_edit_form', Array, Object) (Line: 588)
Drupal\Core\Form\FormBuilder->processForm('node_article_edit_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handl
Comments
Comment #2
santhoshabraham commentedI am having same issue. I am using Bootstrap5 based sub theme.
Comment #3
ben.hamelinI ran into this today, fixed it by disabling the paragraph entity reference fields in the form display settings.
Comment #4
higherform commentedSeeing the same issue on a fairly fresh D9.4.2 + Layout_Paragraphs 2.0.0-beta9 install. Unlike comment #3, the RuntimeException is thrown for a test paragraph type with only text fields ( no entity_reference fields at all) in the paragraph type.
Comment #5
greg boggsmy test paragraph was also a text field.
Comment #6
ben.hamelinSorry I wasn't being clear. It's not the paragraph fields that were an issue here. It was the form display settings on the content type where the layout paragraphs field is defined. At least for my configuration, the Layout Paragraphs enabled entity reference revisions field needs to be "Disabled" in that form display settings.
Comment #7
justin2pin commentedCan someone provide step by step instructions on how to reproduce this error? I'm unclear on exactly what is happening here. Thanks.
Comment #8
justin2pin commentedComment #9
greg boggsSure.
1. Install paragraphs
2. Install layout paragraphs.
3. Add a entity reference revision field to a content type.
4. Create a paragraph type with layout paragraphs enabled and add a text field to the paragraph type.
5. Create a node of that content type, create a paragraph with a text field, save the node.
Expected result:
A text field printed on the node detail page.
Actual result:
Fatal error.
RuntimeException: The subform and parent form must contain the #parents property, which must be an array. Try calling this method from a #process callback instead.
Comment #10
greg boggsI'll run through the paragraphs install again on a fresh D9 project. I'm pretty sure the module is just not working currently. But, it's possible I'm just missing a set up step for layout paragraphs to work like hiding a field from the display.
Comment #11
greg boggsOk, I did a bit of debugging and I narrowed down the error. It seems like layout paragraphs requires a very particular set of widgets and display configurations to function.
If I change the widget on the paragraphs field from paragraphs "stable" to paragraphs legacy, the error goes away and the paragraphs can be placed. But, I don't have any layout options (of course)
If I change the widget from paragraphs legacy to layout paragraphs, I don't get the fatal error anymore, and I can choose layouts, but then the paragraph does not place and I instead get the empty text displayed on the node after save.
Comment #12
greg boggsEssentially what I had done was place a paragraph that had layout support using the regular paragraphs widget which works in legacy mode, but not in stable mode.
Comment #14
justin2pin commented@Greg Boggs - ok great, got it. I think MR89 fixes the issue - merging now.
A few comments:
#parentskey on the affected subform.Thanks for posting this.
Comment #15
justin2pin commentedComment #17
higherform commented