function better_exposed_filters_preprocess_views_exposed_form in Better Exposed Filters 8.3
Same name and namespace in other branches
- 8.5 includes/better_exposed_filters.theme.inc \better_exposed_filters_preprocess_views_exposed_form()
- 8.4 includes/better_exposed_filters.theme.inc \better_exposed_filters_preprocess_views_exposed_form()
Prepares variables for views exposed form templates.
Default template: views-exposed-form.html.twig.
Parameters
array $variables: An associative array containing:
- form: A render element representing the form.
File
- ./
better_exposed_filters.module, line 240 - Allows the use of checkboxes, radio buttons or hidden fields for exposed Views filters.
Code
function better_exposed_filters_preprocess_views_exposed_form(&$variables) {
// Checks if Token module is enabled.
if (!\Drupal::moduleHandler()
->moduleExists('token')) {
return;
}
// Replaces tokens in description field of the exposed filter.
foreach ($variables['form']['#info'] as $name => &$info) {
if (isset($info['description']) && isset($variables['form'][explode('filter-', $name)[1]]['#description'])) {
$info['description'] = \Drupal::service('token')
->replace($info['description']);
$variables['form'][explode('filter-', $name)[1]]['#description'] = $info['description'];
}
}
}