You are here

public function Display::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Form/Ajax/Display.php \Drupal\views_ui\Form\Ajax\Display::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

core/modules/views_ui/src/Form/Ajax/Display.php, line 62
Contains \Drupal\views_ui\Form\Ajax\Display.

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'] = array(
      '#markup' => $this
        ->t('Invalid display id @display', array(
        '@display' => $display_id,
      )),
    );
    return $form;
  }

  // Get form from the handler.
  $form['options'] = array(
    '#theme_wrappers' => array(
      'container',
    ),
    '#attributes' => array(
      'class' => array(
        '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;
}