Views exposed filters for a date field use a text input type, which won't allow using the date picking options built into core. Changing that input type to date appears to allow using a date picker.

Steps to Reproduce

  1. Create a view with an exposed filter on a date field.
  2. Display the view.
  3. For the for the date exposed filter inspect the field type>li>

Desired Behavior

A date picker should be available to users to select dates with like:

Exposed Filter with Date

Accomplished changing the HTML using a web browser inspector to:

<input data-drupal-selector="edit-field-webny-news-date-value" type="date" id="edit-field-webny-news-date-value" name="field_webny_news_date_value" value="" size="30" maxlength="128" class="form-text">

Current Behavior

No date picker is available to users to select:

Exposed Filter with Date Field as Text

Used web browser inspector to identify the input type:

<input data-drupal-selector="edit-field-webny-news-date-value" type="text" id="edit-field-webny-news-date-value" name="field_webny_news_date_value" value="" size="30" maxlength="128" class="form-text">
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggmarshall created an issue. See original summary.

greggmarshall’s picture

BTW if someone can give me a hint where to look, I am willing to attempt creating a patch.

greggmarshall’s picture

Issue summary: View changes
unstatu’s picture

Hi @greggmarshall,

I would change the issue's status to Feature request since the date filter works properly.

If you want to create the patch I think you should go to core/modules/views/src/Plugin/views/filter/Date.php. The method that builds the form item is called valueForm. Good luck!

unstatu’s picture

Category: Bug report » Feature request
unstatu’s picture

Issue tags: +DrupalCampES
pashupathi nath gajawada’s picture

Assigned: Unassigned » pashupathi nath gajawada

Im looking into it.

greggmarshall’s picture

Status: Active » Needs review
FileSize
678 bytes

Here's a first cut at a simple patch. It seemed like the easiest approach.

Status: Needs review » Needs work

The last submitted patch, 8: views_exposed_filter-2710793-8.patch, failed testing.

greggmarshall’s picture

This might be a duplicate of https://www.drupal.org/node/2648950?

deminy’s picture

Experienced same issue. Applied patch #8 and looked fine. Will post an update if I notice any issue with the patch. Thanks

deminy’s picture

As a side note, patch in #8 won't help to resolve following PHP notice:

Notice: Undefined index: type in Drupal\views\Plugin\views\filter\Date->acceptExposedInput() (line 129 of ....../core/modules/views/src/Plugin/views/filter/Date.php)

This PHP notice could be fixed by efforts to be made on ticket "Use form element of type date instead textfield when selecting a date in an exposed filter".

Lendude’s picture

Version: 8.0.6 » 8.3.x-dev
Assigned: pashupathi nath gajawada » Unassigned

Yeah I think this is covered by #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter, the notice raised in #12 is also discussed at some length there.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

benjy’s picture

Status: Needs work » Closed (duplicate)

Closing as duplicate as per #13, also not I have a contrib module that adds this feature - http://drupal.org/project/date_popup

akalam’s picture