Postponed (maintainer needs more info)
Project:
Drupal core
Version:
main
Component:
views.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Mar 2016 at 11:21 UTC
Updated:
16 Nov 2025 at 19:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
leksat commentedComment #3
leksat commentedComment #4
leksat commentedComment #5
dawehnerSome test coverage would be sort of nice.
You can use
$this->view->requestinstead.Comment #6
dawehnerComment #8
leksat commentedAfter some usage of #2, I found that it makes much more sense to preserve only some parameters, not all of them.
Comment #9
leksat commentedComment #12
bceyssensReapplied patch #8 to the 3.x branch
Comment #13
yogeshmpawarComment #14
yogeshmpawarAny Update on this issue ?
Comment #15
rocketeerbkw commentedI was having issues using this with facets. The facet identifier (like
f[0]) was being double encoded and not recognized. I fixed this by decoding the name of the hidden form element.Comment #18
seanb#15 worked for me! Thanks.
Comment #19
aspilicious commentedThis patch needs tests, but it works great in production.
Comment #22
fernly commentedComment #23
jelle_sReroll of #15
Comment #25
matthijsReroll of #23 with an additional
!empty()check to prevent issues on views without this option set.Comment #28
panchukPatch #25 works well for me.
Tested with 9.3.9 core version.
Comment #29
ranjith_kumar_k_u commentedRe-rolled #25 for 9.4
Comment #31
tim-dielsI was just investigating the exposed form and query parameters and found out this issue. Thanks for all the work done.
It is working for me in the following situation:
Comment #32
alexpottThis method should have an @inheritdoc.
This code doesn't look right. Even though there is some protection because a user has to enter the list a of query parameter names in the URL, I'm really not sure about allowing stuff from query parameters to become $form array names. If you manage to do # something then all sorts of interesting things become possible.
Comment #33
davemybes commentedWe've been using patch #23 for years and it's worked great for us. However, I'm building a new View with an exposed filter (no facets) that I want to use with Better Exposed Filters. With this patch in place, I cannot save the BEF settings to properly enable it. I get past the first page to choose it as the style for exposed forms, but cannot save the next settings page where you choose the widget for each exposed filter. The following error appears in the logs.
TypeError: explode(): Argument #2 ($string) must be of type string, array given in explode() (line 120 of /docroot/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php)If I remove the patch things work as normal, but of course, our page with facets on now breaks.
If I enable BEF with the patch removed, then add the patch back afterwards, the Views-generated page throws a fatal error and I once again cannot save the BEF settings:
Error: Cannot create references to/from string offsets in Drupal\Component\Utility\NestedArray::setValue() (line 155 of /docroot/core/lib/Drupal/Component/Utility/NestedArray.php)This happens with both BEF 8.x-5.2 and 6.0.1, running on Drupal 9.3.22 with either patch #23 or patch #25.
Comment #34
nitin_lamaAdded method doc comment as per #32
Comment #35
nitin_lamaComment #36
itaran commentedAdded a few lines to 2681953-29.patch to prevent empty params showing in the URL.
Comment #37
tim-diels@itaran, why did you work with an older patch? Why is there no interdiff for the reviewers to easily see what is changed? And you did not follow the suggestions alexpott made...
So we have no idea in what state your patch is in...
Comment #39
skyredwangTested #34 with Facets. Steps:
1. Go to edit the views of interest
2. Expand "Advanced" section
3. Click "Exposed form style: Settings"
4. Put
fin the Preserve query parameters from URL5. Save and clear cache
It works.
Comment #40
sidgrafix commentedTested #36 Works Great (this feature should definitely be added)
+1 (awesomesauce) saved me from having to use hook_form_views_exposed_form_alter() to modify the submitted query parameters for the exposed filter.
Specifically useful when having other view blocks on page that use contextual filters with setting "provide default value" -> "Type: Query parameter" which updates the content in those blocks when the set parameters are passed by URL from custom links that provide those additional parameters.
Comment #41
nicklasmf commented#36 works for me as well.
Comment #42
tim-dielsI've added the code back from #34 and created an interdiff with #36.
Still need to address point 2 and 3 from #32
Comment #43
luksakComment #44
aaron.ferris commentedPatch from #42 is working well for me, we have a search implementation that has custom query parameters that were being lost on exposed form search. Although that's not specifically facets, but I believe the issue is the same.
Comment #45
leksat commentedConfirming the issue with Better Exposed Filters described in #33. Somehow, when BEF is used, the value already comes as an array. Attaching a patch with a fix.
Comment #47
maxilein commentedThe patch in #45 applies and works with D10.2.5.
With a Exposed form style:Basic (Exposed form in block:no)
Just for completeness if others are looking for orientation:
It does not work with: Basic (with layout) from the https://www.drupal.org/project/vefl module.
For BEF there is an extra patch based on this patch. https://www.drupal.org/project/better_exposed_filters/issues/3119947#com...
Comment #50
simeonkesmev commentedThe extra empty parameter check from #36 and added in #42 broke the handling of array parameters (such as facets) for me. I've fixed it by first cleaning the variable mixing and then deleting this check as It looks to me that is already handled in
if (!isset($form[$name]) && !empty($query[$name]) && ($value = $query[$name]) !== '') {Comment #51
vensiresThe existence of this patch initially troubled me into thinking I need this patch but for the specific use case this issue was created I think we are already fine using the Search API module. Unless you are using facets without indexed views (using search_api) which I think is not possible...
The functionality was already built in #2378945: Facets are lost by Views on keyword search and it's provided - without using any patches - in the Query settings form:

So the main question here is... do we still need issue?
Comment #52
gge commentedAnother use case where this patch is useful: https://www.drupal.org/project/calendar_view/issues/3403103
Comment #53
vensiresI add #3403103: Stay on same month/week after exposed filtering as a related issue then. But if we are to do anything in Drupal core, we have to update the issue summary since the initial one (using search_api & facets) is not valid anymore.
Comment #54
jeffersonpatron commentedI create this patch ONLY for Drupal V10.3.1
Patch include the update for this files:
views.data_types.schema.yml
ExposedFormPluginBase.php
Comment #56
zviryatko commentedAdded support for Reset button.
Comment #57
smustgrave commentedWanted to bump 1 more time for an IS update before closing.
Comment #58
smustgrave commentedI asked about this to one of the view maintainers and summary will need to be updated for a modern use case. Appears it was useful for facets at one point but no longer the case. New features typically need to hit a 80% usefulness for others and this right now does not feel like that.
Will leave open for others to update or respond but may be closed in 3 months.
Comment #59
maxilein commentedThe patch does not look overly complex... so lines of code vs usefulness is more than reasonable.
And it is any use case where you need to have an URL-based integration, parameter passing to a form or a filter that you want to call multiple times or just views development, where you make changes to a view and want to test with the same parameters again, without manually entering them each time you test the changes you made ...