You are here

public function AdminSettingsForm::submitForm in Role Theme Switcher 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/AdminSettingsForm.php, line 131

Class

AdminSettingsForm
Provides the theme switcher configuration form.

Namespace

Drupal\role_theme_switcher\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $data = [];
  foreach (user_role_names() as $rid => $role) {
    $data[$rid] = $form_state
      ->getValue('role_theme_switcher')[$rid];
  }
  $this
    ->config('role_theme_switcher.settings')
    ->set('roles', $data)
    ->save();
}