function FilterPluginBase::prepareFilterSelectOptions
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::prepareFilterSelectOptions()
- 8.9.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::prepareFilterSelectOptions()
- 11.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::prepareFilterSelectOptions()
Sanitizes the HTML select element's options.
The function is recursive to support optgroups.
1 call to FilterPluginBase::prepareFilterSelectOptions()
- FilterPluginBase::exposedTranslate in core/
modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php - Make some translations to a form item to make it more suitable to exposing.
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ FilterPluginBase.php, line 1320
Class
- FilterPluginBase
- Base class for Views filters handler plugins.
Namespace
Drupal\views\Plugin\views\filterCode
protected function prepareFilterSelectOptions(&$options) {
foreach ($options as $value => $label) {
// Recurse for optgroups.
if (is_array($label)) {
$this->prepareFilterSelectOptions($options[$value]);
}
elseif (is_object($label) && isset($label->option)) {
$this->prepareFilterSelectOptions($options[$value]->option);
}
else {
// Cast the label to a string since it can be an object.
// @see \Drupal\Core\StringTranslation\TranslatableMarkup
$options[$value] = strip_tags(Html::decodeEntities((string) $label));
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.