Skip to content

Preserve custom query parameters in index search forms#7639

Open
BriceFab wants to merge 1 commit into
EasyCorp:5.xfrom
BriceFab:feature/preserve-search-query-parameters
Open

Preserve custom query parameters in index search forms#7639
BriceFab wants to merge 1 commit into
EasyCorp:5.xfrom
BriceFab:feature/preserve-search-query-parameters

Conversation

@BriceFab
Copy link
Copy Markdown

@BriceFab BriceFab commented Jun 5, 2026

Fixes #7640

Summary

Browsers discard the query string of GET forms when they are submitted. EasyAdmin already works around this for:

However, other query parameters (custom menu context like _status, sort state, etc.) are preserved in links generated by AdminUrlGenerator, but lost when submitting the index search form in real browsers. This has been known since #1573.

This PR generalizes the existing approach by preserving all remaining query parameters as hidden fields in the search form.

Changes

  • Add SearchDto::getPreservedQueryParameters() to return current query params minus reserved EasyAdmin keys (query, page, filters, batch params, etc.)
  • Render those parameters as hidden fields in layout.html.twig (same comment/pattern as filters.html.twig)
  • Add unit and functional tests

Test plan

  • SearchDtoTest::testGetPreservedQueryParameters
  • SearchAllTermsTest::testSearchPreservesCustomQueryParameters

Related issues

@BriceFab BriceFab force-pushed the feature/preserve-search-query-parameters branch 2 times, most recently from dd1f248 to b4bac0d Compare June 5, 2026 18:44
GET search forms discard the action URL query string in browsers. Reuse the
same hidden-field approach already used for filters and the filters modal so
custom context parameters (e.g. menu-driven list views) and sort state survive
search submissions.

Fixes EasyCorp#7640
Related to EasyCorp#1573, EasyCorp#4707
@BriceFab BriceFab force-pushed the feature/preserve-search-query-parameters branch from b4bac0d to da8696a Compare June 5, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve custom query parameters in index search forms

1 participant