public static function LayoutBuilderIdsConfigureSection::layoutBuilderIdsConfigureSectionSubmitForm in Layout builder ids 2.0.x
File
- src/
EventSubscriber/ LayoutBuilderIdsConfigureSection.php, line 114
Class
- LayoutBuilderIdsConfigureSection
- Add section id to layout builder sections.
Namespace
Drupal\layout_builder_ids\EventSubscriberCode
public static function layoutBuilderIdsConfigureSectionSubmitForm(array &$form, FormStateInterface $form_state) {
// Get the layout builder id from the form.
$layout_builder_id = $form_state
->getValue([
'layout_settings',
'layout_builder_id',
], NULL);
// If there is a layout builder id, store it.
if ($layout_builder_id !== NULL) {
// Get the form object from the form state.
$formObject = $form_state
->getFormObject();
// Get the layout.
$layout = $formObject
->getLayout();
// Load in the config for this section.
$configuration = $layout
->getConfiguration();
// Set the layout builder id in config variable.
$configuration['layout_builder_id'] = Html::getId($layout_builder_id);
// Set the config for this section.
$layout
->setConfiguration($configuration);
}
}