18

I'm using Drupal 7 with views 3.我正在使用带有视图 3 的 Drupal 7。

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?我对日期字段使用了公开的过滤器,并且我想提供从日期弹出窗口中为日期过滤器选择日期的选项?我怎样才能做到这一点?

3 Answers  3 个回答     正确答案

14

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:BEF 与日期模块的集成存在一些已知问题;从模块页面:

(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).(注意:对日期模块提供的字段的支持有点奇怪,直到#392836:公开的日期过滤器格式(在视图中)和/或#502824:公开的过滤器(视图)中的日期格式得到解决)。

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.此外,您目前只能将此类过滤器添加到实体字段,而不能添加到属性。关于这一点正在进行各种讨论。

13

You don't need BEF to get popup calendar with exposed view filters. You just need "Date pop up" and "date views" submodules.您不需要 BEF 即可获取带有公开视图过滤器的弹出日历。您只需要“日期弹出”和“日期视图”子模块。

  • When creating new exposed filter in "Filter" dropdown select "Date"在“过滤器”下拉列表中创建新的公开过滤器时,选择“日期”
  • then choose the Date filter然后选择日期过滤器
  • choose a date field (for instance "Date: Date (node)")选择日期字段(例如“日期:日期(节点)”)
  • in extra settings config , in the "Date selection form element" section select "Popup"在额外设置配置中,在“日期选择表单元素”部分中选择“弹出”
  • follow other regular steps. 遵循其他常规步骤。 
0

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)Drupal 9/10 我刚刚做了一个正常的公开过滤器(用于时间戳/日期)字段在日期之间选择将所有默认值保留为空白然后添加(在模块中)

/** * 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');    }  } }

Your Answer  您的答案 



来自   https://drupal.stackexchange.com/questions/32334/date-popup-in-exposed-filter