[Bugfix] Fix submit buttons/inputs handling #1559
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The suggested changes should fix the following issues:
=> values of clicked submit buttons defining a name/value pair, are now correctly included in the request payload
=> Submit buttons/inputs using the
form attribute
and placed outside a form, are now correctly included in the request payload when clicked=>
form
,a
andinput type="submit"
are now processed by htmx not only when the element haschanceOfBeingBoosted
. This fixes the issue where you had to puthx-ext
on the form itself, otherwise the button's own value wouldn't be in the payload.Also, this doesn't seem to do any harm since it doesn't impact the default behaviour when no htmx logic should happen.
htmx:beforeProcessNode
andhtmx:afterProcessNode
are going to be dispatchedprocessVerbs
won't do anything if the element doesn't declare hx-verb attributehasExplicitHttpAction
being false, nothing happens in the following if eitherinitButtonTracking
will be called for any form OR submit button/input that declares the "form" attribute (i.e. outside a form).initButtonTracking
is what fixes the issue in the end, as it's going to properly set the form'sinternalData.lastButtonClicked
when clicking a button that it outside that formname
attribute on multiple HTML form elements results in only first value being sent #1541=> values of clicked submit button/input now correctly add to regular input values with the same name, as it does in a standars form
Notes