public function EmailExampleGetFormPage::validateForm in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/email_example/src/Form/EmailExampleGetFormPage.php \Drupal\email_example\Form\EmailExampleGetFormPage::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
- email_example/
src/ Form/ EmailExampleGetFormPage.php, line 104
Class
- EmailExampleGetFormPage
- File test form class.
Namespace
Drupal\email_example\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!$this->emailValidator
->isValid($form_state
->getValue('email'))) {
$form_state
->setErrorByName('email', $this
->t('That e-mail address is not valid.'));
}
}