You are here

public function LogintobogganRegister::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 ContentEntityForm::validateForm

File

src/Form/LogintobogganRegister.php, line 119

Class

LogintobogganRegister
Provide alternative registration form to include LT components and submit.

Namespace

Drupal\logintoboggan\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);

  // Check email address matches the confirm address if enabled.
  if ($this
    ->config('logintoboggan.settings')
    ->get('confirm_email_at_registration') && $form_state
    ->hasValue('conf_mail')) {
    if ($form_state
      ->getValue('mail') != $form_state
      ->getValue('conf_mail')) {
      $form_state
        ->setErrorByName('conf_mail', $this
        ->t('Your e-mail address and confirmed e-mail address must match.'));
    }
  }
}