You are here

public function AutocompletionConfigurationDeleteForm::submitForm in Search Autocomplete 8

Same name and namespace in other branches
  1. 2.x src/Form/AutocompletionConfigurationDeleteForm.php \Drupal\search_autocomplete\Form\AutocompletionConfigurationDeleteForm::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/AutocompletionConfigurationDeleteForm.php, line 65

Class

AutocompletionConfigurationDeleteForm
Class AutocompletionConfigurationDeleteForm.

Namespace

Drupal\search_autocomplete\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('The autocompletion configuration %label is deleted.', [
    '%label' => $this->entity
      ->label(),
  ]));

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