function Combine::buildOptionsForm
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/Combine.php \Drupal\views\Plugin\views\filter\Combine::buildOptionsForm()
- 8.9.x core/modules/views/src/Plugin/views/filter/Combine.php \Drupal\views\Plugin\views\filter\Combine::buildOptionsForm()
- 11.x core/modules/views/src/Plugin/views/filter/Combine.php \Drupal\views\Plugin\views\filter\Combine::buildOptionsForm()
Overrides FilterPluginBase::buildOptionsForm
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ Combine.php, line 28
Class
- Combine
- Filter handler which allows to search on multiple fields.
Namespace
Drupal\views\Plugin\views\filterCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$this->view
->initStyle();
// Allow to choose all fields as possible
if ($this->view->style_plugin
->usesFields()) {
$options = [];
foreach ($this->view->display_handler
->getHandlers('field') as $name => $field) {
// Only allow clickSortable fields. Fields without clickSorting will
// probably break in the Combine filter.
if ($field->clickSortable()) {
$options[$name] = $field->adminLabel(TRUE);
}
}
if ($options) {
$form['fields'] = [
'#type' => 'select',
'#title' => $this->t('Choose fields to combine for filtering'),
'#description' => $this->t("This filter doesn't work for very special field handlers."),
'#multiple' => TRUE,
'#options' => $options,
'#default_value' => $this->options['fields'],
];
}
else {
$form_state->setErrorByName('', $this->t('You have to add some fields to be able to use this filter.'));
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.