You are here

public function SlideDeleteForm::submitForm in Drupal Slider 8

Same name and namespace in other branches
  1. 8.2 src/Form/SlideDeleteForm.php \Drupal\drupal_slider\Form\SlideDeleteForm::submitForm()

Function submitForm.

Overrides EntityForm::submitForm

File

src/Form/SlideDeleteForm.php, line 42

Class

SlideDeleteForm
Class SlideDeleteForm.

Namespace

Drupal\drupal_slider\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('Slide %label was deleted.', [
    '%label' => $this->entity
      ->label(),
  ]));

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