Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drupal Timefield exposed filter
<?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
You can’t perform that action at this time.