You are here

public function DemoAdminSettings::submitForm in Demonstration site (Sandbox / Snapshot) 8

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/DemoAdminSettings.php, line 67

Class

DemoAdminSettings
This class will return the form demo_admin_settings.

Namespace

Drupal\demo\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('demo.settings');
  foreach (Element::children($form) as $variable) {
    $config
      ->set($variable, $form_state
      ->getValue($form[$variable]['#parents']));
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}