function Display::buildForm

Same name and namespace in other branches
  1. 9 core/modules/views_ui/src/Form/Ajax/Display.php \Drupal\views_ui\Form\Ajax\Display::buildForm()
  2. 10 core/modules/views_ui/src/Form/Ajax/Display.php \Drupal\views_ui\Form\Ajax\Display::buildForm()
  3. 11.x core/modules/views_ui/src/Form/Ajax/Display.php \Drupal\views_ui\Form\Ajax\Display::buildForm()

Overrides FormInterface::buildForm

File

core/modules/views_ui/src/Form/Ajax/Display.php, line 59

Class

Display
Provides a form for editing the Views display.

Namespace

Drupal\views_ui\Form\Ajax

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $executable = $view->getExecutable();
    if (!$executable->setDisplay($display_id)) {
        $form['markup'] = [
            '#markup' => $this->t('Invalid display id @display', [
                '@display' => $display_id,
            ]),
        ];
        return $form;
    }
    // Get form from the handler.
    $form['options'] = [
        '#theme_wrappers' => [
            'container',
        ],
        '#attributes' => [
            'class' => [
                'scroll',
            ],
            'data-drupal-views-scroll' => TRUE,
        ],
    ];
    $executable->display_handler
        ->buildOptionsForm($form['options'], $form_state);
    // The handler options form sets $form['#title'], which we need on the entire
    // $form instead of just the ['options'] section.
    $form['#title'] = $form['options']['#title'];
    unset($form['options']['#title']);
    // Move the override dropdown out of the scrollable section of the form.
    if (isset($form['options']['override'])) {
        $form['override'] = $form['options']['override'];
        unset($form['options']['override']);
    }
    $name = $form_state->get('update_name');
    $view->getStandardButtons($form, $form_state, 'views_ui_edit_display_form', $name);
    return $form;
}

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