Provide a form for setting options.
Overrides HandlerBase::buildExtraOptionsForm
public function buildExtraOptionsForm(&$form, &$form_state) {
$vocabularies = entity_load_multiple('taxonomy_vocabulary');
$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' => t('Vocabulary'),
'#options' => $options,
'#description' => t('Select which vocabulary to show terms for in the regular options.'),
'#default_value' => $this->options['vid'],
);
}
}
$form['type'] = array(
'#type' => 'radios',
'#title' => t('Selection type'),
'#options' => array(
'select' => t('Dropdown'),
'textfield' => t('Autocomplete'),
),
'#default_value' => $this->options['type'],
);
$form['hierarchy'] = array(
'#type' => 'checkbox',
'#title' => t('Show hierarchy in dropdown'),
'#default_value' => !empty($this->options['hierarchy']),
'#states' => array(
'visible' => array(
':input[name="options[type]"]' => array(
'value' => 'select',
),
),
),
);
}