You are here

public function AutobanDeleteForm::submitForm in Automatic IP ban (Autoban) 8

The submit handler for the confirm form.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: An associative array containing the current state of the form.

Overrides EntityForm::submitForm

File

src/Form/AutobanDeleteForm.php, line 58

Class

AutobanDeleteForm
Class AutobanDeleteForm.

Namespace

Drupal\autoban\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Delete the entity.
  $this->entity
    ->delete();

  // Set a message that the entity was deleted.
  $this
    ->messenger()
    ->addMessage($this
    ->t('Autoban rule #%label was deleted.', [
    '%label' => $this->entity
      ->id(),
  ]));

  // Redirect the user to the list controller when complete.
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}