getgrav / getgrav/grav-plugin-form
Form action does not preserve uri.param and uri.query
- Dominant language
- PHP
- Stars
- 64
- Forks
- 80
- Avg merge
- 10h 13m
- Merged PRs (30d)
- 9
Description
... this may be a problem in some use cases
It would be possible to define boolean parameters for the form: preserve_params and preserve_query.
Form definition:
```
form:
name: form
preserve_params: true
preserve_query: true
fields:
...
```
A small change in the forms/default/form.html.twig template:
```
...
{% if (action == base_url_relative) %}
{% set action = base_url_relative ~ '/' ~ page.slug %}
{% endif %}
{# preserve_params & preserve_query - BEGIN #}
{% if form.preserve_params or form.preserve_query %}
{% set action_anchor = action|split('#')[1] ? '#' ~ action|split('#')[1] : '' %}
{% set action = action|split('#')[0] %}
{% if form.preserve_params %}
{% set action = action ~ uri.params %}
{% endif %}
{% if form.preserve_query and uri.query %}
{% set action = action ~ '?' ~ uri.query %}
{% endif %}
{% set action = action ~ action_anchor %}
{% endif %}
{# preserve_params & preserve_query - END #}
{% if form.keep_alive %}
...
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading forms/default/form.html.twig and the form definition shown in the issue. Check how the action currently handles fragments, uri.params, and uri.query, then verify that the preserve_params and preserve_query options retain the intended values without changing existing forms. Done means form actions preserve the selected URI components and anchors when enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100