- Drupal version : 8.2.0
- Module "Better exposed filter" version : 8.x-3.0-alpha1
In short :
I created a view with an exposed filter. When I use the operator "is all of" from my exposed filter, all work. My exposed filter shows some tags in a select/option html list. I download and install the module "Better exposed filter" for display my exposed filter in checkbox instead the select/option html list. If I configure my exposed filter for it display checkboxs, then the view display no result.
In detail :
I created 3 simples contents of type 'articles' :
- Recipe one (tags 'ingredients' : salt, sugar )
- Recipe two (tags 'ingredients' : super, pepper )
- Recipe three (tags 'ingredients' : pepper, salt )
I created a very simple view :
When I do a search, I get two of my article if I select the tag "sugar" with the exposed operator "is all off" : (look the Query, **only one "INNER JOIN"**)
Tags exposed filter is an html select/option list. I want change this style by a list of checkboxs. So, I configure the filter style with the "better exposed filter" module :
When I do that, my view works when I search with the filter exposed operator "is one of". But when I use the filter exposed operator "is all off", no result displayed !
In the new query, I notice there are two "INNER JOIN". The second use an id = 0, the error must be here.
My questions are :
- Do I forget something in my configuration ?
- Is a bug in the module "better exposed filter" ?
- What should I do to operate the operand "is one off" when I display it in list of checkboxs ?
Thanks you :)
This thread is slightly different..the proposed patch was already in my code
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | taxonomy_views_filter_fix.zip | 2.51 KB | dandaman |
Comments
Comment #2
kegilko commentedComment #3
kegilko commentedComment #4
nikolay borisov commentedI can confirm that there is a bug with the BEF checkbox filter output. When "Is all of" is selected.
The default drupal output (multiple select box works as it should, but the checkbox output is returning no values)
PS: also tested it with 8.3.0-alpha1
Comment #5
dandaman commentedI am also having this issue.
I have an exposed form for a taxonomy term. Without BEF, it is a select list with key
term[]=25, and that works.Within BEF and set to use checkboxes, the params submitted are like this:
type[25]=25&type[27]=27&type[26]=26With this submission, Views seems to return no results. The database query looks like this:
Note these snippets of the query:
INNER JOIN {node__field_lighting_type_filter} node__field_lighting_type_filter_value_3 ON node_field_data.nid = node__field_lighting_type_filter_value_3.entity_id AND node__field_lighting_type_filter_value_3.field_lighting_type_filter_target_id = '0'WHERE [....] AND (node__field_lighting_type_filter_value_3.field_lighting_type_filter_target_id = '0')Not sure where the zero join is coming from. Not sure where all the code that creates these joins is either.
Any tips or help on resolving this is much appreciated.
Comment #6
Welsby commentedAlso hitting this issue, only occurs when using checkboxes as opposed to a select.
Comment #7
dandaman commentedIt was noted by a colleague of mine that Better Exposed Filters does work right if "is one of", but not if "is all of". But I guess that makes sense as the 0 option wouldn't stop matches from happening.
By the time Views gets to submitting the form, it seems the checkboxes have a setting for each checkbox, like this:
That is, for each checkbox with a taxonomy term ID, if it is not checked, it's ID is set as a key and the value is set as "0".
In
core/modules/views/src/Form/ViewsExposedForm.php:submitForm()function, it runsCheckboxes::getCheckedCheckboxes()to get rid of empty checkboxes. It then sends that in$view->exposed_raw_input[$key].But then later in
lib/Drupal/Core/Database/QueryCondition.php:addFilter(), it adds conditions for each of$this->handler->tableAliases. But in this case, thetableAliasesdoes actually have a0option in it, which should not be there, in addition to the25,26and27values I was expecting.Comment #8
dandaman commentedA co-worker (jacerider) wrote this little module that creates a new Views field for taxonomy terms that filters out the unwanted checkboxes. This fixes the issue, but it's likely there's a better way to integrate this into the core Views code or the Better Exposed Filters module.
Comment #9
mikeker commentedComment #10
mikeker commentedForgot the tag...
Comment #11
mikeker commentedRetitling to better reflect the issue.
Comment #12
mikeker commentedCurious if the patch in #2687773: Using checkboxes with an "is all of" filter fails if any options are selected (comment #24) fixes this issue for you? Please post back here either way. I would love to fix this in core rather than hack around core in BEF!
Thanks.
Comment #13
mikeker commentedI'm closing this in favor of #2687773: Using checkboxes with an "is all of" filter fails if any options are selected which should fix the underlying issue here. Please test the patch in that issue and report back there if it fixes the problems you're seeing.