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.