You are here

public function SocialAuthSettingsForm::validateForm in Social Auth 8.2

Same name and namespace in other branches
  1. 8 src/Form/SocialAuthSettingsForm.php \Drupal\social_auth\Form\SocialAuthSettingsForm::validateForm()
  2. 3.x src/Form/SocialAuthSettingsForm.php \Drupal\social_auth\Form\SocialAuthSettingsForm::validateForm()

Form validation 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 FormBase::validateForm

File

src/Form/SocialAuthSettingsForm.php, line 132

Class

SocialAuthSettingsForm
Defines a form that configures Social Auth settings.

Namespace

Drupal\social_auth\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $post_login = $values['post_login'];

  // If it is not a valid path.
  if (!in_array($post_login[0], [
    "/",
    "#",
    "?",
  ])) {
    $form_state
      ->setErrorByName('post_login', $this
      ->t('The path is not valid. It must begin with <em>/, #</em> or <em>?</em>'));
  }
}