public function NodeTabForm::validateTestAddress in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Form/NodeTabForm.php \Drupal\simplenews\Form\NodeTabForm::validateTestAddress()
- 3.x src/Form/NodeTabForm.php \Drupal\simplenews\Form\NodeTabForm::validateTestAddress()
Validates the test address.
File
- src/
Form/ NodeTabForm.php, line 244
Class
- NodeTabForm
- Configure simplenews subscriptions of a user.
Namespace
Drupal\simplenews\FormCode
public function validateTestAddress(array $form, FormStateInterface $form_state) {
$test_address = $form_state
->getValue('test_address');
$test_address = trim($test_address);
if (!empty($test_address)) {
$mails = explode(',', $test_address);
foreach ($mails as $mail) {
$mail = trim($mail);
if (!valid_email_address($mail)) {
$form_state
->setErrorByName('test_address', t('Invalid email address "%mail".', array(
'%mail' => $mail,
)));
}
}
$form_state
->set('test_addresses', $mails);
}
else {
$form_state
->setErrorByName('test_address', t('Missing test email address.'));
}
}