public function MailingListImportForm::validateForm in Mailing List 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/ MailingListImportForm.php, line 137
Class
- MailingListImportForm
- Mailing list import.
Namespace
Drupal\mailing_list\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
foreach (preg_split("/\\r\\n|\\r|\\n/", $form_state
->getValue('emails')) as $email) {
if (!empty($email) && !$this->emailValidator
->isValid($email)) {
$form_state
->setErrorByName('emails', $this
->t('%recipient is an invalid email address.', [
'%recipient' => $email,
]));
}
}
}