In an Entity Field Query view I have an exposed filter on the Bundle property. I have selected a couple of bundles as default value and I have selected the "Limit list to selected items" option. "Allow multiple selections" is disabled and the filter is not required.
The exposed filter is displayed as a dropdown select list with the default value being "- Any -". When this value is selected, I expect only the default bundles that I selected to be used for the query, but instead all items are shown, so no filtering is taking place.
In the code of the handler views_handler_filter_in_operator, the method accept_exposed_input contains the following:
// If this is non-multiple and non-required, then this filter will
// participate, but using the default settings, *if* 'limit is true.
if (empty($this->options['expose']['multiple']) && empty($this->options['expose']['required']) && !empty($this->options['expose']['limit'])) {
$identifier = $this->options['expose']['identifier'];
if ($input[$identifier] == 'All') {
return TRUE;
}
}
The problem is that there is no expose setting 'limit'. I think that the "Limit list to selected items" setting was meant here, but that setting has key 'reduce'. When I change 'limit' to 'reduce', the filter behaves like expected.
Comment | File | Size | Author |
---|---|---|---|
#10 | views-in-filter-default-value-1704372-10.patch | 2.54 KB | Jorrit |
|
Comments
Comment #1
Jorrit CreditAttribution: Jorrit commentedPlease see attached patch.
Comment #2
Jorrit CreditAttribution: Jorrit commentedThe following patch contains just the test, so it must fail.
Comment #4
Jorrit CreditAttribution: Jorrit commented#1: views-in-filter-default-value-1704372-1.patch queued for re-testing.
Comment #5
dawehnerTo make it perfect here is a patch which merges the two above, just to be sure that the patch even fixes the new tests.
I'm impressed that you created a test even noone asked you to do so, this happens really really rarely.
Comment #6
Jorrit CreditAttribution: Jorrit commentedThanks, I should have done that too. I saw that Views already has a lot of tests, so adding one was a matter of copying the existing test for this handler and modifying the specific conditions. If I had to write a test from scratch, I probably wouldn't have done it, because the code to setup a test is quite extensive.
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 6 year old patch in #5 does not apply to the latest views 7.x-3.x-dev and if still applicable needs a reroll.
Comment #8
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedRerolled and test added.
Comment #9
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThanks Jorrit, the rerolled patch in #8 fixes this issue for me, but it may need another review before changing the status to RTBC so I'm leaving the status as is for now.
Comment #10
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedI accidentally misnamed the patch file. I am reuploading it with the right name.
Comment #11
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe renamed patch in #10 is still good for me.