You are here

public function ViewEditForm::submitDisplayDelete in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayDelete()

Submit handler to delete a display from a view.

File

core/modules/views_ui/src/ViewEditForm.php, line 634
Contains \Drupal\views_ui\ViewEditForm.

Class

ViewEditForm
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function submitDisplayDelete($form, FormStateInterface $form_state) {
  $view = $this->entity;
  $display_id = $form_state
    ->get('display_id');

  // Mark the display for deletion.
  $displays = $view
    ->get('display');
  $displays[$display_id]['deleted'] = TRUE;
  $view
    ->set('display', $displays);
  $view
    ->cacheSet();

  // Redirect to the top-level edit page. The first remaining display will
  // become the active display.
  $form_state
    ->setRedirectUrl($view
    ->urlInfo('edit-form'));
}