You are here

public function ContentModerationNotificationsDeleteForm::submitForm in Content Moderation Notifications 8

Same name and namespace in other branches
  1. 8.3 src/Form/ContentModerationNotificationsDeleteForm.php \Drupal\content_moderation_notifications\Form\ContentModerationNotificationsDeleteForm::submitForm()
  2. 8.2 src/Form/ContentModerationNotificationsDeleteForm.php \Drupal\content_moderation_notifications\Form\ContentModerationNotificationsDeleteForm::submitForm()

The submit handler for the confirm form.

For entity delete forms, you use this to delete the entity in $this->entity.

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/ContentModerationNotificationsDeleteForm.php, line 78

Class

ContentModerationNotificationsDeleteForm
Class ContentModerationNotificationDeleteForm.

Namespace

Drupal\content_moderation_notifications\Form

Code

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

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

  // Set a message that the entity was deleted.
  drupal_set_message($this
    ->t('Notification %label was deleted.', array(
    '%label' => $this->entity
      ->label(),
  )));

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