You are here

public function BookRemoveForm::submitForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/src/Form/BookRemoveForm.php \Drupal\book\Form\BookRemoveForm::submitForm()
  2. 9 core/modules/book/src/Form/BookRemoveForm.php \Drupal\book\Form\BookRemoveForm::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

core/modules/book/src/Form/BookRemoveForm.php, line 103

Class

BookRemoveForm
Remove form for book module.

Namespace

Drupal\book\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($this->bookManager
    ->checkNodeIsRemovable($this->node)) {
    $this->bookManager
      ->deleteFromBook($this->node
      ->id());
    $this
      ->messenger()
      ->addStatus($this
      ->t('The post has been removed from the book.'));
  }
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}