function ViewEditForm::submitDisplayEnable

Same name in other branches
  1. 9 core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayEnable()
  2. 8.9.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayEnable()
  3. 11.x core/modules/views_ui/src/ViewEditForm.php \Drupal\views_ui\ViewEditForm::submitDisplayEnable()

Submit handler to enable a disabled display.

File

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

Class

ViewEditForm
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function submitDisplayEnable($form, FormStateInterface $form_state) {
    $view = $this->entity;
    $id = $form_state->get('display_id');
    // setOption doesn't work because this would might affect upper displays
    $view->getExecutable()->displayHandlers
        ->get($id)
        ->setOption('enabled', TRUE);
    // 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,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.