You are here

public function LogintobogganSettingsForm::validateForm in LoginToboggan 8

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/LogintobogganSettingsForm.php, line 274

Class

LogintobogganSettingsForm
Configure search settings for this site.

Namespace

Drupal\logintoboggan\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  if ($this
    ->config('user.settings')
    ->get('register') != 'visitors' && $form_state
    ->getValue('immediate_login_on_register') == '1') {
    $form_state
      ->setErrorByName('immediate_login_on_register', $this
      ->t('The main account settings do
       not allow visitors to register without admin approval but Logintoboggan is set for immediate login.
       You must switch to visitor registration to use immediate login'));
  }
  $redirect_register = $form_state
    ->getValue('redirect_on_register');
  if (!empty($redirect_register) && substr($redirect_register, 0, 1) != '/') {
    $form_state
      ->setErrorByName('redirect_on_register', $this
      ->t('redirects must start with a forward slash: e.g. / or /node/1'));
  }
  $redirect_confirm = $form_state
    ->getValue('redirect_on_confirm');
  if (!empty($redirect_confirm) && substr($redirect_confirm, 0, 1) != '/') {
    $form_state
      ->setErrorByName('redirect_on_confirm', $this
      ->t('redirects must start with a forward slash: e.g. / or  /node/1'));
  }
}