I'm using Drupal 7 with views 3.
I have used an exposed filter for a date field and I want to provide option to choose date from datepopup for date filter? How can I do this?
The Better Exposed Filters module integrates with the date type fields, including the date popup. You can use this module to easily add an exposed filter with the date popup.
There are some known issues with BEF's integration with the date module; from the module page:
(Note: Support for fields supplied by the Date module is a little funky until #392836: Exposed Date filter format (in Views) and/or #502824: Date format in exposed filter (views) are resolved).
Also, you can only add this type of filter to entity fields at the moment, not properties. There are various discussions going on about this.
BEF
is date_views
.
Commented
Jul 4, 2012 at 12:43
You don't need BEF to get popup calendar with exposed view filters. You just need "Date pop up" and "date views" submodules.
Drupal 9/10 I Just did a normal exposed filter (for a timestamp / date) field Selected between dates left all defaults blank then added (in a module)
/**
* Implements hook_form_ID_alter().
*/
function SOMEMODULE_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$view_ids = ['my_view_id'];
if ($form_id === 'views_exposed_form') {
$view = $form_state->getStorage('view');
if (!empty($view) && in_array($view['view']->id(), $view_ids)) {
$form['field_timestamp_wrapper']['field_timestamp']['min']['#type'] = 'date';
$form['field_timestamp_wrapper']['field_timestamp']['max']['#type'] = 'date';
$form['field_timestamp_wrapper']['field_timestamp']['min']['#title'] = t('From');
$form['field_timestamp_wrapper']['field_timestamp']['max']['#title'] = t('To');
}
}
}