You are here

public function ViewEditForm::submitDisplayDisable in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayDisable()
  2. 9 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayDisable()

Submit handler to disable display.

File

core/modules/views_ui/src/ViewEditForm.php, line 653

Class

ViewEditForm
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function submitDisplayDisable($form, FormStateInterface $form_state) {
  $view = $this->entity;
  $id = $form_state
    ->get('display_id');
  $view
    ->getExecutable()->displayHandlers
    ->get($id)
    ->setOption('enabled', FALSE);

  // Store in cache
  $view
    ->cacheSet();

  // Redirect to the top-level edit page.
  $form_state
    ->setRedirect('entity.view.edit_display_form', [
    'view' => $view
      ->id(),
    'display_id' => $id,
  ]);
}