You are here

public function CampaignMonitorListDeleteForm::submitForm in Campaign Monitor 8.2

Same name and namespace in other branches
  1. 8 src/Form/CampaignMonitorListDeleteForm.php \Drupal\campaignmonitor\Form\CampaignMonitorListDeleteForm::submitForm()

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

src/Form/CampaignMonitorListDeleteForm.php, line 112

Class

CampaignMonitorListDeleteForm
Defines a confirmation form for deleting mymodule data.

Namespace

Drupal\campaignmonitor\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($this->campaignMonitorManager
    ->deleteList($this
    ->id())) {
    $this
      ->messenger()
      ->addStatus($this
      ->t('The list has been deleted.'));
  }
  else {
    $this
      ->messenger()
      ->addError($this
      ->t('The list could not be deleted.'));
  }
  $url = Url::fromRoute('campaignmonitor.refresh_lists');
  $form_state
    ->setRedirectUrl($url);
}