public function Display::buildForm in Drupal 9
Same name and namespace in other branches
- 8 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 59
Class
- Display
- Provides a form for editing the Views display.
Namespace
Drupal\views_ui\Form\AjaxCode
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;
}