Display::buildForm

public Display::buildForm(array $form, FormStateInterface $form_state)

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 57

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;
}
doc_Drupal
2016-10-29 09:02:34
Comments
Leave a Comment

Please login to continue.