public function TaxonomyIndexTid::buildExtraOptionsForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::buildExtraOptionsForm()
Provide a form for setting options.
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 106 - Contains \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid.
Class
- TaxonomyIndexTid
- Filter by term id.
Namespace
Drupal\taxonomy\Plugin\views\filterCode
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
$vocabularies = $this->vocabularyStorage
->loadMultiple();
$options = array();
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'] = array(
'#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'] = array(
'#type' => 'radios',
'#title' => $this
->t('Selection type'),
'#options' => array(
'select' => $this
->t('Dropdown'),
'textfield' => $this
->t('Autocomplete'),
),
'#default_value' => $this->options['type'],
);
$form['hierarchy'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Show hierarchy in dropdown'),
'#default_value' => !empty($this->options['hierarchy']),
'#states' => array(
'visible' => array(
':input[name="options[type]"]' => array(
'value' => 'select',
),
),
),
);
}