I have a general "Search for nodes" view with many optional exposed filters; two of them are the From and To components of a Date field. I have Optional and Lock Operator set on them, and in the Filters section the Value is left blank, as is the Option. In RC5 this resulted in the Date fields being initially left blank on the search form, and if the form was submitted that way, no Date filtering would be applied. I considered this to be the correct behavior for an optional exposed filter.

After upgrading to RC6 (and re-creating the filters for good measure), this behavior has changed: Now the Date fields both initially contain the current date, instead of being blank. If the form is submitted this way, the filter will be applied and it is near certain that you will end up with an empty results page (unless you have a node whose From and To dates are both set to the exact minute at which you happen to be doing the search). The only way to avoid this unwanted filtering is to delete the pre-entered values, and even then, they re-appear after submitting the form.

Comments

karens’s picture

When I test this I see that the query is doing the correct filtering (if you use the Devel module to see the query that is executed, it's correctly doing no filtering), but the wrong values show up in the exposed filter. This is the result of a recent fix to get the exposed filter to show the default values, since before this it was *always* empty, even if it wasn't supposed to be.

I'll investigate.

karens’s picture

Status: Active » Fixed

OK, fix committed.

Grantovich’s picture

Status: Fixed » Active

Thank you very much for the quick fix, but unfortunately it looks like the issue is only partially solved. After applying this fix and clearing my Views cache, the date inputs are now initially blank when I visit the view, as they should be. But after submitting the form once, leaving the date inputs blank, they become pre-filled with the current date again. The view is otherwise unchanged, but submitting once again (now with the pre-filled values in place) will result in the filters being applied as before.

karens’s picture

Status: Active » Fixed

There were two separate additional problems. One is that I was assuming the exposed filter had the same delta as the regular filters, but it does not (not all filters are necessarily exposed), and the other is that the query is set up before the filter form is processed, so I had to add a step to get info about the exposed filter in my filter handling so it would do the right thing, including ignoring options like 'now' if the date was deliberately set to be empty in the exposed filter.

I think this is now working right.

akahn’s picture

Hi KarenS,

I'm curious if you mean that this is fixed in 2.0-rc7 or in 2.x-dev. Let me know.

Thanks,
Alex

karens’s picture

It was fixed on September 2, so that was after rc7 was issued. It should be fixed now in both -dev and the new 2.1 release.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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