Skip to content

Instantly share code, notes, and snippets.

@shaneonabike
Created September 11, 2018 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneonabike/27236c923a1ae88875c3f513ea20ddb6 to your computer and use it in GitHub Desktop.
Save shaneonabike/27236c923a1ae88875c3f513ea20ddb6 to your computer and use it in GitHub Desktop.
Drupal Timefield exposed filter integration (template.php)
/**
* Preprocess output of form element
*
*/
function yourtheme_preprocess_form_element(&$vars) {
if (!empty($vars['element']['#id']) && ($vars['element']['#id'] == 'edit-hour')) {
// Add special class for JS to work properly but we need to edit the #children value :/
$children = $vars['element']['#children'];
if (!empty($children)) {
$vars['element']['#children'] = str_replace('form-text', 'form-text edit-timefield-timepicker filter-project-event-time', $children);
} else $vars['#attributes']['class'][] = 'edit-timefield-timepicker';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment