Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Create a view with an exposed filter on a date field.
- Display the view.
- 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:
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:
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">
Comment | File | Size | Author |
---|---|---|---|
#8 | views_exposed_filter-2710793-8.patch | 678 bytes | greggmarshall |
ExposedFilterWithDateType.png | 14.86 KB | greggmarshall | |
ExposedFilterWithTextType.png | 14.26 KB | greggmarshall |
Comments
Comment #2
greggmarshallBTW if someone can give me a hint where to look, I am willing to attempt creating a patch.
Comment #3
greggmarshallComment #4
unstatu CreditAttribution: unstatu as a volunteer commentedHi @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!Comment #5
unstatu CreditAttribution: unstatu as a volunteer commentedComment #6
unstatu CreditAttribution: unstatu as a volunteer commentedComment #7
pashupathi nath gajawada CreditAttribution: pashupathi nath gajawada as a volunteer and at Melity commentedIm looking into it.
Comment #8
greggmarshallHere's a first cut at a simple patch. It seemed like the easiest approach.
Comment #10
greggmarshallThis might be a duplicate of https://www.drupal.org/node/2648950?
Comment #11
deminyExperienced same issue. Applied patch #8 and looked fine. Will post an update if I notice any issue with the patch. Thanks
Comment #12
deminyAs a side note, patch in #8 won't help to resolve following PHP notice:
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".
Comment #13
LendudeYeah 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.
Comment #16
benjy CreditAttribution: benjy at Unearthed commentedClosing as duplicate as per #13, also not I have a contrib module that adds this feature - http://drupal.org/project/date_popup
Comment #17
akalam CreditAttribution: akalam commented