function TaxonomyIndexTid::buildExtraOptionsForm
Same name in other branches
- 9 core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::buildExtraOptionsForm()
- 8.9.x core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::buildExtraOptionsForm()
- 11.x core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::buildExtraOptionsForm()
Overrides HandlerBase::buildExtraOptionsForm
1 call to TaxonomyIndexTid::buildExtraOptionsForm()
- TaxonomyIndexTidDepth::buildExtraOptionsForm in core/
modules/ taxonomy/ src/ Plugin/ views/ filter/ TaxonomyIndexTidDepth.php - Provide a form for setting options.
1 method overrides TaxonomyIndexTid::buildExtraOptionsForm()
- TaxonomyIndexTidDepth::buildExtraOptionsForm in core/
modules/ taxonomy/ src/ Plugin/ views/ filter/ TaxonomyIndexTidDepth.php - Provide a form for setting options.
File
-
core/
modules/ taxonomy/ src/ Plugin/ views/ filter/ TaxonomyIndexTid.php, line 125
Class
- TaxonomyIndexTid
- Filter by term id.
Namespace
Drupal\taxonomy\Plugin\views\filterCode
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
$vocabularies = $this->vocabularyStorage
->loadMultiple();
$options = [];
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
if ($this->options['limit']) {
// We only do this when the form is displayed.
if (empty($this->options['vid'])) {
$first_vocabulary = reset($vocabularies);
$this->options['vid'] = $first_vocabulary->id();
}
if (empty($this->definition['vocabulary'])) {
$form['vid'] = [
'#type' => 'radios',
'#title' => $this->t('Vocabulary'),
'#options' => $options,
'#description' => $this->t('Select which vocabulary to show terms for in the regular options.'),
'#default_value' => $this->options['vid'],
];
}
}
$form['type'] = [
'#type' => 'radios',
'#title' => $this->t('Selection type'),
'#options' => [
'select' => $this->t('Dropdown'),
'textfield' => $this->t('Autocomplete'),
],
'#default_value' => $this->options['type'],
];
$form['hierarchy'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show hierarchy in dropdown'),
'#default_value' => !empty($this->options['hierarchy']),
'#states' => [
'visible' => [
':input[name="options[type]"]' => [
'value' => 'select',
],
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.