I've run into a case that I didn't handle correctly over at #336531: Fix the UI for boolean filters. If you set a boolean exposed filter to be "optional", the exposed filter gets a nice <any> option. However, the radios to select the default filter value when you're configuring the filter itself doesn't give you this choice. Discussed this with Earl in IRC, and he agrees that if the filter is exposed, there should be a 3rd radio for <any>, and there should be a little validation that only lets you pick <any> if the "Optional" checkbox is selected. I'll work on a patch in a little while, just wanted to get the issue started...

Comments

dww’s picture

Status: Active » Needs work
StatusFileSize
new1.83 KB

This sort of does the trick. It correctly adds the 3rd radio and the validation.

The one edge case that's still broken is if you have an exposed filter with <Any> selected and saved, then you press the "Hide" button, the 3rd radio goes away (as it should) but the validation is a little screwy. Originally, the validation message would just fire, but it wouldn't make any sense since neither <Any> nor "Optional" are even visible. I discussed with Earl in IRC, and he suggested that the form builder should ensure the #default_value is valid, which this patch does. However, due to some weirdness with the JS form stuff, this new #default_value isn't being used to auto-select the first choice as intended. I don't fully understand why, but Earl says this approach might need to be abandoned in favor of just using a more generic validation error message that makes sense in this edge case.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB

After further discussion with Earl in IRC, we figured the best we could do for this edge case was to use a more generic error message text so it made sense in both contexts:

"You must select a value unless this is an optional exposed filter."

Makes for a much smaller patch, at least. ;)

merlinofchaos’s picture

Status: Needs review » Fixed

Commited to 2.x and 3.x branches. Can't believe I let this sit for 6 months. :/

Status: Fixed » Closed (fixed)

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

AntiNSA’s picture

Status: Closed (fixed) » Active

What if you are not using radios?

merlinofchaos’s picture

Status: Active » Closed (fixed)

Please don't re-open closed issues unless there is an obvious problem with the fix that was made.

AntiNSA’s picture

sorry

mikeker’s picture

Status: Closed (fixed) » Active
StatusFileSize
new1.77 KB

Apologies if it is not appropriate to re-open this issue... The patch in #2 does not handle the "Optional" option consistent with other Views data type handlers. For example, in a node->type filter, the <Any> option is only available if "Optional" is checked.

I wonder, though, if the original intent of this patch was to include the Any option so that a user could select, for example, both published and unpublished nodes. If that's the case, then perhaps we should expose the "Force single" option as one of the exposed filter options.

Anyhow, attached is a patch to make boolean data handlers consistent with other data handlers. A side effect of this patch is that there is no longer a need for the value_validate() routine. I can open another issue regarding "Force single" for boolean data handlers if needed.

mikeker’s picture

StatusFileSize
new2.09 KB

Slight update in this patch: it also handles the #default_value properly. (Changes (bool) TRUE/FALSE to (int) 1/0.

dagmar’s picture

Status: Active » Needs review

Changing to correct status.

merlinofchaos’s picture

Status: Needs review » Needs work

mikeker: The reason we did not go with the solution you provided is that you have to click optional and then click update to make the "Any" option appear. That actually adds confusion to the UI.

The only way we could make this work is if we added a dependency to the radio. Which is going to be a pain.

esmerel’s picture

http://drupal.org/node/432208 looks to be a dup of this issue.

Bilmar’s picture

ManyNancy’s picture

Subscribe

peterum’s picture

patch doesnt work for me with an exposed flag filter :( i still can only choose true or false as the default value or rather flagged / unflagged which translates into true and false at the frontend

esmerel’s picture

Status: Needs work » Closed (fixed)

If this is still a problem, it should be a new issue and worked against 6.x-3.x or 7.x-3.x; the original issue was corrected.