You are here

public function LoginRedirectionForm::submitForm in Redirect after login 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/LoginRedirectionForm.php, line 73
Contains \Drupal\redirect_after_login\Form\LoginRedirectionForm.

Class

LoginRedirectionForm

Namespace

Drupal\redirect_after_login\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $loginUrls = [];
  foreach ($this->allUser as $user => $name) {
    if ($form_state
      ->getValue($user) == '<front>') {
      $loginUrls[$user] = '/';
    }
    else {
      $loginUrls[$user] = $form_state
        ->getValue($user);
      $form_state
        ->getValue($user);
    }
  }
  $this
    ->config('redirect_after_login.settings')
    ->set('login_redirection', $loginUrls)
    ->save();
  parent::submitForm($form, $form_state);
}