Skip to content

Instantly share code, notes, and snippets.

@esafwan
Forked from jez500/d8-views-exp-form-alter.php
Created September 4, 2018 07:06
Show Gist options
  • Save esafwan/ab47771bbc49ac65651f50e775bb3400 to your computer and use it in GitHub Desktop.
Save esafwan/ab47771bbc49ac65651f50e775bb3400 to your computer and use it in GitHub Desktop.
Drupal 8 - Hook form alter views exposed form
<?php
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$view_names = array('my_view_name');
$view = $form_state->getStorage('view');
if ($form_id == 'views_exposed_form' && in_array($view['view']->id(), $view_names)) {
// Do some shilzzle.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment