public function ListMailchimpEventsForMember::submitForm in Mailchimp 2.x
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/
mailchimp_events/ modules/ mailchimp_events_example/ src/ Form/ ListMailchimpEventsForMember.php, line 114
Class
- ListMailchimpEventsForMember
- A sample form for listing Mailchimp Events for a member.
Namespace
Drupal\mailchimp_events_example\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$email = $form_state
->getValue('email');
$list = $form_state
->getValue('list');
$count = $form_state
->getValue('count');
$offset = $form_state
->getValue('offset');
$fields = explode(',', $form_state
->getValue('fields'));
$exclude_fields = explode(',', $form_state
->getValue('exclude_fields'));
$events = mailchimp_events_list_member_events($list, $email, $count, $offset, $fields, $exclude_fields);
$form_state
->set('events', $events);
$form_state
->setRebuild();
$debug = $this
->t("Called function: mailchimp_events_list_member_events(%list, %email, %count, %offset, %fields, %exclude_fields).", [
'%list' => $list,
'%email' => $email,
'%count' => $count,
'%offset' => $offset,
'%fields' => print_r($fields, TRUE),
'%exclude_fields' => print_r($exclude_fields, TRUE),
]);
if ($events !== FALSE) {
$this
->messenger()
->addStatus($debug);
}
else {
$this
->messenger()
->addError($debug);
$this
->messenger()
->addError($this
->t('No results returned. Check the <a href=":watchdog">logs for Mailchimp</a>', [
':watchdog' => Url::fromRoute('dblog.overview')
->toString(),
]));
}
}