You are here

public function GlobalSettingsForm::submitForm in Layout Builder Component Attributes 1.2.x

Same name and namespace in other branches
  1. 1.0.x src/Form/GlobalSettingsForm.php \Drupal\layout_builder_component_attributes\Form\GlobalSettingsForm::submitForm()
  2. 1.1.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 103

Class

GlobalSettingsForm
Global settings form.

Namespace

Drupal\layout_builder_component_attributes\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->getEditable(static::SETTINGS);

  // Loop through configuration categories.
  foreach ($this->categories as $category) {
    $cat_config = $form_state
      ->getValue($category);

    // Convert the FAPI values into booleans for config storage.
    foreach ($cat_config as $attribute => $value) {
      $cat_config[$attribute] = $value ? TRUE : FALSE;
    }
    $config
      ->set($category, $cat_config);
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}