function DisplayLink::buildOptionsForm
Same name in other branches
- 9 core/modules/views/src/Plugin/views/area/DisplayLink.php \Drupal\views\Plugin\views\area\DisplayLink::buildOptionsForm()
- 8.9.x core/modules/views/src/Plugin/views/area/DisplayLink.php \Drupal\views\Plugin\views\area\DisplayLink::buildOptionsForm()
- 11.x core/modules/views/src/Plugin/views/area/DisplayLink.php \Drupal\views\Plugin\views\area\DisplayLink::buildOptionsForm()
Overrides AreaPluginBase::buildOptionsForm
File
-
core/
modules/ views/ src/ Plugin/ views/ area/ DisplayLink.php, line 33
Class
- DisplayLink
- Views area display_link handler.
Namespace
Drupal\views\Plugin\views\areaCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$allowed_displays = [];
$displays = $this->view->storage
->get('display');
foreach ($displays as $display_id => $display) {
if (!$this->isPathBasedDisplay($display_id)) {
unset($displays[$display_id]);
continue;
}
$allowed_displays[$display_id] = $display['display_title'];
}
$form['description'] = [
[
'#markup' => $this->t('To make sure the results are the same when switching to the other display, it is recommended to make sure the display:'),
],
[
'#theme' => 'item_list',
'#items' => [
$this->t('Has a path.'),
$this->t('Has the same filter criteria.'),
$this->t('Has the same sort criteria.'),
$this->t('Has the same pager settings.'),
$this->t('Has the same contextual filters.'),
],
],
];
if (!$allowed_displays) {
$form['empty_message'] = [
'#markup' => '<p><em>' . $this->t('There are no path-based displays available.') . '</em></p>',
];
}
else {
$form['display_id'] = [
'#title' => $this->t('Display'),
'#type' => 'select',
'#options' => $allowed_displays,
'#default_value' => $this->options['display_id'],
'#required' => TRUE,
];
$form['label'] = [
'#title' => $this->t('Label'),
'#description' => $this->t('The text of the link.'),
'#type' => 'textfield',
'#default_value' => $this->options['label'],
'#required' => TRUE,
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.