public function GlobalSettingsForm::submitForm in Layout Builder Component Attributes 1.1.x
Same name and namespace in other branches
- 1.2.x src/Form/GlobalSettingsForm.php \Drupal\layout_builder_component_attributes\Form\GlobalSettingsForm::submitForm()
- 1.0.x src/Form/GlobalSettingsForm.php \Drupal\layout_builder_component_attributes\Form\GlobalSettingsForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ GlobalSettingsForm.php, line 90
Class
- GlobalSettingsForm
- Global settings form.
Namespace
Drupal\layout_builder_component_attributes\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->getEditable(static::SETTINGS);
$form_values = [
'allowed_block_attributes' => $form_state
->getValue('allowed_block_attributes'),
'allowed_block_title_attributes' => $form_state
->getValue('allowed_block_title_attributes'),
'allowed_block_content_attributes' => $form_state
->getValue('allowed_block_content_attributes'),
];
// Convert the FAPI values into booleans for config storage.
foreach ($form_values as $category => $cat_config) {
foreach ($cat_config as $attribute => $value) {
$form_values[$category][$attribute] = $value ? TRUE : FALSE;
}
}
$config
->set('allowed_block_attributes', $form_values['allowed_block_attributes']);
$config
->set('allowed_block_title_attributes', $form_values['allowed_block_title_attributes']);
$config
->set('allowed_block_content_attributes', $form_values['allowed_block_content_attributes']);
$config
->save();
parent::submitForm($form, $form_state);
}