public function MailingListSubscribeForm::submitForm in Mailgun 8
Form submission 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 FormInterface::submitForm
File
- modules/
mailgun_mailing_lists/ src/ Form/ MailingListSubscribeForm.php, line 93
Class
- MailingListSubscribeForm
- Provides list subscription form.
Namespace
Drupal\mailgun_mailing_lists\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$email = $form_state
->getValue('email');
try {
$this->mailgunClient
->mailingList()
->member()
->create($this->listAddress, $email, $email);
$this
->messenger()
->addMessage($this
->t("You've successfully subscribed."));
} catch (HttpClientException $e) {
$this
->messenger()
->addMessage($this
->t("Error occurred. Please try again later."));
}
}