function NodeTermData::buildOptionsForm

Same name and namespace in other branches
  1. 8.9.x core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::buildOptionsForm()
  2. 10 core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::buildOptionsForm()
  3. 11.x core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::buildOptionsForm()

Overrides RelationshipPluginBase::buildOptionsForm

File

core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php, line 62

Class

NodeTermData
Relationship handler to return the taxonomy terms of nodes.

Namespace

Drupal\taxonomy\Plugin\views\relationship

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $vocabularies = $this->vocabularyStorage
        ->loadMultiple();
    $options = [];
    foreach ($vocabularies as $voc) {
        $options[$voc->id()] = $voc->label();
    }
    $form['vids'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Vocabularies'),
        '#options' => $options,
        '#default_value' => $this->options['vids'],
        '#description' => $this->t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'),
    ];
    parent::buildOptionsForm($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.