public function InviteByEmailBlockForm::validateForm in Invite 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
- modules/
invite_by_email/ src/ Form/ InviteByEmailBlockForm.php, line 58
Class
- InviteByEmailBlockForm
- Class InviteByEmailBlockForm.
Namespace
Drupal\invite_by_email\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$user = \Drupal::currentUser();
$mail = $user
->getEmail();
$values = $form_state
->getValues();
if (!empty($values['email']) && $values['email'] == $mail) {
$form_state
->setErrorByName('email', $this
->t("You couldn't invite yourself."));
}
}