public function BootstrapLayout::submitConfigurationForm in Bootstrap Layout Builder 2.x
Same name and namespace in other branches
- 1.x src/Plugin/Layout/BootstrapLayout.php \Drupal\bootstrap_layout_builder\Plugin\Layout\BootstrapLayout::submitConfigurationForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides LayoutDefault::submitConfigurationForm
File
- src/
Plugin/ Layout/ BootstrapLayout.php, line 659
Class
- BootstrapLayout
- A layout from our bootstrap layout builder.
Namespace
Drupal\bootstrap_layout_builder\Plugin\LayoutCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
// The tabs structure.
$layout_tab = [
'ui',
'tab_content',
'layout',
];
$style_tab = [
'ui',
'tab_content',
'appearance',
];
$settings_tab = [
'ui',
'tab_content',
'settings',
];
// Save section label.
$this->configuration['label'] = $form_state
->getValue(array_merge($settings_tab, [
'label',
]));
// Container type.
$this->configuration['container'] = $form_state
->getValue(array_merge($layout_tab, [
'container_type',
]));
// Styles tab.
$this->configuration['container_wrapper']['bootstrap_styles'] = $this->stylesGroupManager
->submitStylesFormElements($form['ui']['tab_content']['appearance'], $form_state, $style_tab, $this->configuration['container_wrapper']['bootstrap_styles'], 'bootstrap_layout_builder.styles');
// Container classes from advanced mode.
if (!$this
->sectionSettingsIsHidden()) {
$this->configuration['container_wrapper_classes'] = $form_state
->getValue(array_merge($settings_tab, [
'container',
'container_wrapper_classes',
]));
$this->configuration['container_wrapper_attributes'] = Yaml::decode($form_state
->getValue(array_merge($settings_tab, [
'container',
'container_wrapper_attributes',
])));
}
// Gutter Classes.
$this->configuration['remove_gutters'] = $form_state
->getValue(array_merge($layout_tab, [
'remove_gutters',
]));
// Row classes from advanced mode.
if (!$this
->sectionSettingsIsHidden()) {
$this->configuration['section_classes'] = $form_state
->getValue(array_merge($settings_tab, [
'row',
'section_classes',
]));
$this->configuration['section_attributes'] = Yaml::decode($form_state
->getValue(array_merge($settings_tab, [
'row',
'section_attributes',
])));
}
$breakpoints = $form_state
->getValue(array_merge($layout_tab, [
'breakpoints',
]));
// Save breakpoints configuration.
if ($breakpoints) {
$this
->saveBreakpoints($breakpoints);
foreach ($this
->getPluginDefinition()
->getRegionNames() as $key => $region_name) {
// Save layout region classes.
$this->configuration['layout_regions_classes'][$region_name] = $this
->getRegionClasses($key, $breakpoints);
// Cols classes from advanced mode.
if (!$this
->sectionSettingsIsHidden()) {
$this->configuration['regions_classes'][$region_name] = $form_state
->getValue(array_merge($settings_tab, [
'regions',
$region_name . '_classes',
]));
$this->configuration['regions_attributes'][$region_name] = Yaml::decode($form_state
->getValue(array_merge($settings_tab, [
'regions',
$region_name . '_attributes',
])));
}
}
}
else {
foreach ($this
->getPluginDefinition()
->getRegionNames() as $key => $region_name) {
// Cols classes from advanced mode.
if (!$this
->sectionSettingsIsHidden()) {
$this->configuration['regions_classes'][$region_name] = $form_state
->getValue(array_merge($settings_tab, [
'regions',
$region_name . '_classes',
]));
$this->configuration['regions_attributes'][$region_name] = Yaml::decode($form_state
->getValue(array_merge($settings_tab, [
'regions',
$region_name . '_attributes',
])));
}
}
}
}