Problem/Motivation
The views exposed filter form adds the filter values to $view->exposed_raw_input
in \Drupal\views\Form\ViewsExposedForm::submitForm()
. I found what I consider to be a bug in the way the views exposed form handles multivalue filters.
Steps to reproduce:
- Edit the admin/content overview
- Edit the 'type' filter
- Select 'article' as default value
- Check 'Allow multiple selections'
- Create enough content to allow a pager
The following now happens:
In the pager, &article=article
is added to the URL. This is supposed to be &type[]=article
. When you submit the exposed filter first and click the pager after that, you get both in the URL &type%5B0%5D=article&article=article
. This is because the $view->exposed_raw_input
data is not correct.
Proposed resolution
The issue is in \Drupal\views\Form\ViewsExposedForm::submitForm()
. The code for checkboxes does not use the key of the filter field. I think this should be fixed.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#16 | 2943163-16.patch | 708 bytes | d.novikov |
#10 | interdiff-7-10.txt | 6.79 KB | seanB |
#10 | 2943163-10.patch | 4.29 KB | seanB |
#7 | interdiff-3-6.txt | 633 bytes | seanB |
#7 | 2943163-6.patch | 3.88 KB | seanB |
Comments
Comment #2
seanBPatch is attached, please review!
Comment #3
seanBNow with tests. Also changing the IS and title since the issue about the wrong values in
$view->exposed_raw_input
, the pager is just how I noticed it.Comment #6
LendudeLooking nice already.
This can actually be a kernel test like this, maybe add it to ExposedFormRenderTest or something?
Copy/paste left over, needs update to current test.
Comment #7
seanBOk missed 1 small thing, this should do it.
Comment #9
LendudeNice! Back to 'needs work' for #6
Comment #10
seanBWe seem to have cross posted so I missed #6. Thanks for the review. Updated the patch.
Comment #11
LendudeFix looks good, tests look good, feedback has been addressed, @seanB++
Comment #13
catchCommitted/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!
Comment #16
d.novikov CreditAttribution: d.novikov as a volunteer commented#10 does not work for filters with named keys. E.g., views date filter utilizes max and min keys for date fields. For example, we get the following structure for imaginary event date field:
Instead, it should be:
As a side-off, it breaks views pager links when using date filters.
Proposed solution attached.
Comment #17
mpolishchuck CreditAttribution: mpolishchuck at Alpha Web Group for Dazzle commentedThe patch #16 works for me with Drupal 8.6.7.
URLs look consistent for filters and for filters+pager links.
I'm wondering why it's not posted to some open issue and not considered to merge. Maybe I've missed something?
Comment #18
gcbThis issue still exists, and #16 resolves it for me (core 8.6.13). It is as d.novikov describes: in my case, we have a view using location proximity filtering, and the named keys are getting munched by this bug when building the pager, resulting in a pager that removes filters.
This issue should be re-opened, or a new issue created referencing this one.
Comment #19
smazr.e. #16, #17 & #18:
It looks like that issue was resolved (for 8.7) as a result of https://www.drupal.org/node/2987598., as the issue over there has made the same as #16,