Problem/Motivation
The granularity filter that was requested in https://www.drupal.org/project/smart_date/issues/3055994 was meant to be available when building a View, but it is now visible to end users of the View whenever a date filter is exposed. Because the new Date.php filter plugin overrides the core Date.php plugin, this happens to all date fields with exposed filters, not just smart_date fields.
Steps to reproduce
Build a View with an exposed date filter. Note that granularity is now exposed, and there is no way to hide it. Also, the exposed date selector does not have a date picker widget, but is just a text field.
Proposed resolution
Modify the valueForm() function in src/Plugin/views/filter/Date.php to check what form it is part of, and only modify the Views edit form, not the exposed filter form.
Undo whatever is preventing the exposed filters from having a date picker widget.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | smart_date-granularity_exposed-3300325-3.patch | 895 bytes | mandclu |
| Screenshot from 2022-07-27 15-58-23.png | 41.46 KB | benstallings |
Comments
Comment #2
benstallings commentedHere's a patch to disable the new plugin until it is fixed.
Comment #3
mandclu commentedThe attached patch should preserve the granularity option in the filter configuration but hide it when exposed.
Comment #4
tobiasbAfter applying the patch, the granularity filter is not anymore visible with enabled in between operator.
Comment #5
mandclu commented@tobiasb I'm not sure how to interpret your feedback. Do you mean that it works as expected in hiding the granularity option on an exposed field? Or that it has unexpectedly disappeared as an option when configuring the filter?
Comment #6
tobiasbThat the patch works. ;-)
Comment #7
mandclu commentedThanks for the feedback! I'll get this merged in and roll a new release shortly.
Comment #9
mandclu commentedMerged in, rolling a new release.
Comment #10
benstallings commentedI'm still seeing that the date picker widgets do not work for exposed filters. We need to not lose that functionality. Thanks!
Comment #11
mandclu commentedCore doesn't appear to use date pickers on date fields in exposed form. What solution were you using to add the date pickers?
Comment #12
benstallings commentedI stand corrected. I guess we were getting that functionality from https://www.drupal.org/node/2982968 , which modifies the core date filter but not, of course, your copy of the filter. Since I don't need granularity, I can continue to use my patch from #2 above.
Comment #13
mandclu commentedIt might not be that much of a lift to add the datepicker to the exposed filters here, if we think it would add significant value.