You are here

public function FlagDisableConfirmForm::submitForm in Flag 8.4

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

src/Form/FlagDisableConfirmForm.php, line 80

Class

FlagDisableConfirmForm
Provides the flag enable/disable confirmation form.

Namespace

Drupal\flag\Form

Code

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

  // Toggle the flag state.
  if ($this->flag
    ->status()) {
    $this->flag
      ->disable();
  }
  else {
    $this->flag
      ->enable();
  }

  // Save The flag entity.
  $this->flag
    ->save();

  // Redirect to the flag admin page.
  $form_state
    ->setRedirect('entity.flag.collection');
}