- Issue created by @erichomanchuk
- πΊπΈUnited States joegl
We are also seeing this when we extend the core
layout_builder
module'sMultiWidthLayoutBase
class.When we switch layouts in the layout section pop-up and there the option selected for the current layout doesn't exist in the
getWidthOptions()
for the new layout, it spits out this error. It doesn't appear to have any affect and the error is actually coming from thesubmitConfigurationForm()
method, and notbuildConfigurationForm()
.For example, we have a three column and two column layouts both extending the
MultiWidthLayoutBase
:Three column:
class ThreeColumn extends MultiWidthLayoutBase implements PluginFormInterface { protected function getWidthOptions() { return [ '100' => '100%' ]; } }
Two column:
class TwoColumn extends MultiWidthLayoutBase implements PluginFormInterface { protected function getWidthOptions() { return [ '50-50' => '50% - 50%', '33-67' => '33% - 67%', '67-33' => '67% - 33%', ]; } }
When we switch from ThreeColumn to TwoColumn it complains because the 100 option doesn't exist in the TwoColumn (and vice-versa).
- πΊπΈUnited States joegl
To expand on this, I noticed in the
LayoutParagraphsBehavior
buildBehaviorForm()
method there is a supposed to be an ajax callback that fires (ajaxUpdateOptions
) when a layout is selected:$form['layout'] = [ '#title' => $this->t('Choose a layout:'), '#type' => 'layout_select', '#options' => $available_layouts, '#default_value' => $default_value, '#ajax' => [ 'wrapper' => $wrapper_id, 'callback' => [$this, 'ajaxUpdateOptions'], 'progress' => [ 'type' => 'throbber', ], ], '#weight' => 0, ];
The callback itself seems like it's supposed to rebuild the
$form['config']
options (where the width options are):public function ajaxUpdateOptions(array $form, FormStateInterface $form_state) { $triggering_element = $form_state->getTriggeringElement(); $parents = $triggering_element['#parents']; array_splice($parents, -1, 1, ['config']); $config_form = NestedArray::getValue($form, $parents); if (isset($config_form)) { return $config_form; } return []; }
However, when a layout is selected this callback is not firing, and the
submitBehaviorForm()
method is ran instead. I'm not sure if that's how it's supposed to work or not. - πΊπΈUnited States joegl
It looks like this error isn't "harmless" but actually causes paragraphs to be lost when switching between different layouts that have existing paragraphs in regions. Linked relevant issue.