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

Breadcrumb

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

function TaxonomyIndexTid::buildOptionsForm

Provide "link to term" option.

Overrides PrerenderList::buildOptionsForm

File

core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php, line 85

Class

TaxonomyIndexTid
Field handler to display all taxonomy terms of a node.

Namespace

Drupal\taxonomy\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $form['link_to_taxonomy'] = [
        '#title' => $this->t('Link this field to its term page'),
        '#type' => 'checkbox',
        '#default_value' => !empty($this->options['link_to_taxonomy']),
    ];
    $form['limit'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Limit terms by vocabulary'),
        '#default_value' => $this->options['limit'],
    ];
    $options = [];
    $vocabularies = $this->vocabularyStorage
        ->loadMultiple();
    foreach ($vocabularies as $voc) {
        $options[$voc->id()] = $voc->label();
    }
    $form['vids'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Vocabularies'),
        '#options' => $options,
        '#default_value' => $this->options['vids'],
        '#states' => [
            'visible' => [
                ':input[name="options[limit]"]' => [
                    'checked' => TRUE,
                ],
            ],
        ],
    ];
    parent::buildOptionsForm($form, $form_state);
}

API Navigation

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