You are here

public function SimpleMailSettingsController::submitForm in Simple Mail 2.0.x

Same name and namespace in other branches
  1. 8 src/Controller/SimpleMailSettingsController.php \Drupal\simple_mail\Controller\SimpleMailSettingsController::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/Controller/SimpleMailSettingsController.php, line 92

Class

SimpleMailSettingsController
Returns responses for Simple Mail module routes.

Namespace

Drupal\simple_mail\Controller

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('simple_mail.settings');
  $storage = $form_state
    ->getStorage();

  // Save all the Simple Mail configuration items from $form_state.
  foreach ($form_state
    ->getValues() as $key => $value) {
    if (in_array($key, $storage['keys'])) {
      $config
        ->set($key, $value);
    }
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}