Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included referenced form values on GET submit #3118

Open
geoffrey-eisenbarth opened this issue Jan 10, 2025 · 0 comments
Open

Included referenced form values on GET submit #3118

geoffrey-eisenbarth opened this issue Jan 10, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@geoffrey-eisenbarth
Copy link
Contributor

PR #3094 added support for including form values when a button outside a form is used for submission.

Currently, if the request is GET, this will not happen:

// for a non-GET include the related form, which may or may not be a parent element of elt
if (verb !== 'get') {
  processInputValue(processed, priorityFormData, errors, getRelatedForm(elt), validate)
}

this should be changed to

if (verb !== 'get' || (elt.form && elt.hasAttribute('form'))) { }

However, tests will need to be added to make sure we're not altering existing "link-like" behavior. Comments from Carson for reference:

htmx has not submitted values for GETs that occur within a form so that link-like things do not include them when navigating. This behavior may not be ideal but we can't change it without breaking backwards compatibility. (In general at this point backwards compatibility is becoming more important than correctness in htmx.)

I think the situation where the user has explicitly called out a form via the form attribute is obvious enough to fix so I'm in favor of this change so long as it minimizes any additional changes, in particular with an eye towards backwards compatibility.

and

basically a form always includes all. params, even if it's a GET
everything else sends enclosing form values on a non-GET

@Telroshan Telroshan added the enhancement New feature or request label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants