public function WebformEmailReplyForm::validateForm in Webform Email Reply 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/ WebformEmailReplyForm.php, line 185 - Contains \Drupal\webform_email_reply\Form\WebformEmailReplyForm.
Class
Namespace
Drupal\webform_email_reply\FormCode
public function validateForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
$from_email = $form_state
->getValue([
'details',
'from_address',
]);
if (!valid_email_address($from_email)) {
$form_state
->setErrorByName('details][from_address', $this
->t('The from email address, @email, is not valid. Please enter a valid email address.', [
'@email' => $from_email,
]));
}
$valid_email = explode(',', $form_state
->getValue([
'details',
'email',
]));
foreach ($valid_email as $email) {
if (!valid_email_address($email)) {
$form_state
->setErrorByName('details][email', $this
->t('The email address, @email, is not valid. Please enter a valid email address.', [
'@email' => $email,
]));
}
}
}