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.

Comments

BenStallings created an issue. See original summary.

benstallings’s picture

StatusFileSize
new639 bytes

Here's a patch to disable the new plugin until it is fixed.

mandclu’s picture

Status: Active » Needs review
StatusFileSize
new895 bytes

The attached patch should preserve the granularity option in the filter configuration but hide it when exposed.

tobiasb’s picture

After applying the patch, the granularity filter is not anymore visible with enabled in between operator.

mandclu’s picture

@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?

tobiasb’s picture

That the patch works. ;-)

mandclu’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the feedback! I'll get this merged in and roll a new release shortly.

  • mandclu committed d06e8f4 on 3.6.x
    Issue #3300325 by mandclu: Granularity filter is exposed to end users
    
mandclu’s picture

Status: Reviewed & tested by the community » Fixed

Merged in, rolling a new release.

benstallings’s picture

Status: Fixed » Needs work

I'm still seeing that the date picker widgets do not work for exposed filters. We need to not lose that functionality. Thanks!

mandclu’s picture

Core doesn't appear to use date pickers on date fields in exposed form. What solution were you using to add the date pickers?

benstallings’s picture

Status: Needs work » Fixed

I 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.

mandclu’s picture

It 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.