Cannot nest sections

Created on 2 May 2025, 13 days ago

Problem/Motivation

I want to be able to nest sections, but i cannot add a section in another section. Even using experimental widget and settings max nested value.

Steps to reproduce

I have a section paragraph configured as section layout paragraph and multiple layout paragraphs (which can also have sections and layouts, but this part works).
I configure thanks to layout_builder an article content type with paragraph field with experimental layout paragraph widget.
The widget is configured to allow maximum of 10 nesting elements.
I can add a first section, but i cannot add a nested section

Proposed resolution

Digging on module, i try :

  • Hard code default settings in LayoutParagraphLayouts constructor to add nesting_depth to 10 by default
  • Hard code default widget settings to add nesting_depth to 10 by default

None of those work.

Looking at \Drupal\layout_paragraphs\Form\LayoutParagraphsBuilderForm::buildForm()

      $render_display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode);
      $renderer = $render_display->getRenderer($field_name);
      $layout_paragraphs_settings = $renderer->getSettings() + ['reference_field_view_mode' => $view_mode];

call \Drupal\Core\Entity\Entity\EntityViewDisplay::getRenderer()

    // Instantiate the formatter object from the stored display properties.
    if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) {

Except at this point, $configuration is setted with default settings including nesting_depth = 0.

{
  "view_mode": "default",
  "link": "",
  "preview_view_mode": "default",
  "form_display_mode": "default",
  "nesting_depth": 0,
  "require_layouts": 0,
  "empty_message": ""
}

Don't know why, but layout settings is initiate with default values i cannot configure.

The fact is when i load the choose component widget for a nested section (so in paragraph field of paragraph section), we don't know the form display (the paragraph field of parent node), and so the widget settings.

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇫🇷France goz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @goz
  • 🇫🇷France goz

    If i use the edit form, everything works fine.
    Issue is only when i want to edit sections from the node display

  • 🇫🇷France goz

    I confirm this work without using layout builder to build my node page

  • 🇫🇷France goz

    i find a workaround :

    1. Configure default node display without layout builder and set widget with nesting_depth to 10.
    2. Add full content view mode and configure it with layout builder.

    Now, i can add nested sections. When i want to add the nested section, i guess it can find the settings from the no-layout builder default view mode

  • 🇫🇷France goz

    FYI, when layout builder was configured on default view mode, i had to add the first section from the edit form, because paragraph layout edition link was not displaying.
    There is definitively an issue when layout builder is configured on default view mode

Production build 0.71.5 2024