Created
September 11, 2018 13:28
-
-
Save shaneonabike/bee47684cac5d9a32e23aaccb1ad46e1 to your computer and use it in GitHub Desktop.
Drupal Timefield exposed filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Alter the exposed form for the projects view | |
* | |
* $form | |
* Relative form that is being created | |
* $form_state | |
* Existing statee | |
*/ | |
function yourmodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) { | |
// Determine if hour is attached as exposed filter | |
if (!empty($form['hour'])) { | |
// Add the JS code to make this happen | |
$js_settings = array('filter-project-event-time' => array( | |
'showLeadingZero' => TRUE, | |
'timeSeparator' => ':', | |
'showPeriod' => FALSE, | |
'showPeriodLabels' => FALSE, | |
'periodSeparator' => '', | |
'amPmText' => '', | |
'showMinutesLeadingZero' => TRUE, | |
'showCloseButton' => TRUE, | |
'closeButtonText' => t('Done'), | |
'showNowButton' => FALSE, | |
'showDeselectButton' => FALSE, | |
'deselectButtonText' => t('Deselect'), | |
'myPosition' => 'left top', | |
'atPosition' => 'left bottom', | |
) | |
); | |
$form['#attached']['library'][] = array('timefield', 'timepicker'); | |
$form['#attached']['js'] = array( | |
drupal_get_path('module', 'timefield') . '/js/timefield.js', | |
array( | |
'data' => array('timefield' => $js_settings), | |
'type' => 'setting', | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment