Problem/Motivation

Followup from https://www.drupal.org/node/2687773 his was originally reported in the Better Exposed Filters issue queue, but has since been moved to Drupal core and now to the search_api queue.

Steps to reproduce:
1. Create a view based on a search_api index.
2. Create a filter based on a indexed field datasource and select "Is all of"f and thick the "Allow multiple selections" option and click the Apply button
3. Enable by views settings show query
4. Go back editing you view and filter now you see field = 1, field = 0, field = 0, field = 0, field =0 depend on how many options you have.

When using checkboxes to render exposed form options, the FormAPI returns unchecked checkboxes as 0 => 0 entries. This doesn't cause any problems with OR filter ("is any of") but does with AND filters ("is all of").

Comments

Lennard Westerveld created an issue. See original summary.

lennard westerveld’s picture

Rewrited the original patch from #2687773 to search_api SearchApiFilterTrait.

drunken monkey’s picture

Status: Active » Postponed

Thanks for reporting this!
I'm doubtful, though, whether "some other module alters the form and breaks the functionality" can really be considered our problem. Furthermore, there might be instances where 0 (or even "") is indeed a valid value. Neither this patch nor the one for Core seems to take that into account.
However, if the Core patch gets committed, we should probably still follow to stay consistent.

rosk0’s picture

Version: 8.x-1.3 » 8.x-1.x-dev
Status: Postponed » Needs review
StatusFileSize
new700 bytes
new1.02 KB

Core patch was committed on 5 September 2017 so I think we must follow. Spent couple hours today until found the source of the issue. Also moved filtering to the most beginning of the opHelper() to have proper early exit on

['option_1' =>0, 'option_2' => 0]

values.

drunken monkey’s picture

Thanks a lot for bumping this! Apparently, I forgot to follow the Core issue (and it’s also not linked here).
Patch looks good and makes sense (apart from my earlier reservations – but see there). So: committed.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

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