public function MailingListSubscribeForm::validateForm in Mailgun 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
- modules/
mailgun_mailing_lists/ src/ Form/ MailingListSubscribeForm.php, line 78
Class
- MailingListSubscribeForm
- Provides list subscription form.
Namespace
Drupal\mailgun_mailing_lists\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$email = $form_state
->getValue('email');
try {
if ($this->mailgunClient
->mailingList()
->member()
->show($this->listAddress, $email)) {
$form_state
->setErrorByName('name', $this
->t("You are already subscribed to this list."));
}
} catch (HttpClientException $e) {
return;
}
}