function FormHooks::formViewsExposedFormAlter
Same name and namespace in other branches
- main core/themes/admin/src/Hook/FormHooks.php \Drupal\admin\Hook\FormHooks::formViewsExposedFormAlter()
Implements hook_form_FORM_ID_alter() for views_exposed_form.
Attributes
#[Hook('form_views_exposed_form_alter')]
File
-
core/
themes/ admin/ src/ Hook/ FormHooks.php, line 511
Class
- FormHooks
- Provides form related hook implementations.
Namespace
Drupal\admin\HookCode
public function formViewsExposedFormAlter(array &$form, FormStateInterface $form_state) : void {
$view = $form_state->getStorage()['view'];
$view_title = $view->getTitle();
// Add a label so screen readers can identify the purpose of the exposed
// form without having to scan content that appears further down the page.
$form['#attributes']['aria-label'] = $this->t('Filter the contents of the %view_title view', [
'%view_title' => $view_title,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.