You are here

public function InviteSettingsForm::submitForm in User External Invite 8

Same name and namespace in other branches
  1. 2.0.x src/Form/InviteSettingsForm.php \Drupal\user_external_invite\Form\InviteSettingsForm::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/InviteSettingsForm.php, line 197

Class

InviteSettingsForm

Namespace

Drupal\user_external_invite\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('user_external_invite.settings');
  $values = $form_state
    ->getValues();

  // Loop through and save form values.
  foreach ($values as $key => $value) {

    // Since there are non-user input values, we need to check for the prefix
    // added to all variables to filter out values we don't want to save.
    if (strpos($key, 'user_external_invite') !== FALSE) {
      $config
        ->set($key, $value);
    }
  }

  // Save form values to be loaded as defaults.
  $config
    ->save();
  parent::submitForm($form, $form_state);
}