public function ContactFormEditForm::validateForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/contact/src/ContactFormEditForm.php \Drupal\contact\ContactFormEditForm::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
- core/
modules/ contact/ src/ ContactFormEditForm.php, line 114 - Contains \Drupal\contact\ContactFormEditForm.
Class
- ContactFormEditForm
- Base form for contact form edit forms.
Namespace
Drupal\contactCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
// Validate and each email recipient.
$recipients = explode(',', $form_state
->getValue('recipients'));
foreach ($recipients as &$recipient) {
$recipient = trim($recipient);
if (!$this->emailValidator
->isValid($recipient)) {
$form_state
->setErrorByName('recipients', $this
->t('%recipient is an invalid email address.', array(
'%recipient' => $recipient,
)));
}
}
$form_state
->setValue('recipients', $recipients);
}