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
CommentFileSizeAuthor
#6 Untitled.png24.53 KBben.hamelin
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Greg Boggs created an issue. See original summary.

santhoshabraham’s picture

I am having same issue. I am using Bootstrap5 based sub theme.

ben.hamelin’s picture

I ran into this today, fixed it by disabling the paragraph entity reference fields in the form display settings.

higherform’s picture

Seeing 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.

greg boggs’s picture

my test paragraph was also a text field.

ben.hamelin’s picture

StatusFileSize
new24.53 KB

Sorry 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.

justin2pin’s picture

Can someone provide step by step instructions on how to reproduce this error? I'm unclear on exactly what is happening here. Thanks.

justin2pin’s picture

Status: Active » Postponed (maintainer needs more info)
greg boggs’s picture

Status: Postponed (maintainer needs more info) » Active

Sure.

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.

greg boggs’s picture

I'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.

greg boggs’s picture

Ok, 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.

greg boggs’s picture

Essentially 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.

justin2pin’s picture

Title: The subform and parent form must contain the #parents property » Layout Paragraphs behavior plugin is Incompatible with the Paragraphs stable field widget

@Greg Boggs - ok great, got it. I think MR89 fixes the issue - merging now.

A few comments:

  • For Layout Paragraphs to work correctly and provide the drag-and-drop editing UI, you need to use the "Layout Paragraphs" field widget on your content type.
  • But, not choosing the Layout Paragraphs field widget shouldn't break your site -- which is what is happening right now.
  • I'm changing the title of this issue to "Layout Paragraphs behavior plugin is Incompatible with the Paragraphs stable field widget".
  • MR89 fixes the issue by explicitly setting a default for the #parents key on the affected subform.
  • I added an automated test to make sure that LP doesn't break your site if you use the Paragraphs stable field widget with a paragraph type that has the LP behavior enabled.

Thanks for posting this.

justin2pin’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.