Skip to content

Instantly share code, notes, and snippets.

@opi
Created November 28, 2017 11:13
Show Gist options
  • Save opi/327717ed5750d6311aeb4abcf233c3e4 to your computer and use it in GitHub Desktop.
Save opi/327717ed5750d6311aeb4abcf233c3e4 to your computer and use it in GitHub Desktop.
Drupal8 - Custom views exposed form suggestions
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYTHEME_theme_suggestions_views_exposed_form_alter(array &$suggestions, array $vars) {
// form[#id] pattern is views-exposed-form-VIEWNAME-DISPLAY
// We need to remove the 'views-exposed-form-' part
// and to replace underscores with dashes
$suggestions[] = 'views_exposed_form__' . str_replace(
['views-exposed-form-', '-'],
['', '_'],
$vars['form']['#id']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment