Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DisplayLink.php

function 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\area

Code

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,
        ];
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal