public function CampaignMonitorListCreateForm::validateForm in Campaign Monitor 8
Create list validation form handler, which calls the API to create the list. This is done here to ensure better user feedback on failure.
Parameters
array $form:
\Drupal\Core\Form\FormStateInterface $form_state:
Return value
boolean FALSE on failure
Overrides FormBase::validateForm
File
- src/
Form/ CampaignMonitorListCreateForm.php, line 72
Class
- CampaignMonitorListCreateForm
- Configure campaignmonitor settings for this site.
Namespace
Drupal\campaignmonitor\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$options = [
'listname' => $values['listname'],
'UnsubscribePage' => $values['UnsubscribePage'],
'ConfirmationSuccessPage' => $values['ConfirmationSuccessPage'],
'ConfirmedOptIn' => $values['ConfirmedOptIn'],
];
$result = campaignmonitor_create_list($options);
if ($result != 'success') {
$form_state
->setErrorByName('', $result);
}
parent::validateForm($form, $form_state);
}