Update docs/#parameters with note about button values
See original GitHub issueEdGuiness wrote:
Reading the docs I note that
…an element that causes a request will include its value if it has one…
So therefore I had expected this…
<button hx-post="serverAction"
hx-target="closest .insert-me"
hx-swap="afterbegin"
value="abc"
class="btn btn-primary btn-sm">
…to send the value “abc” to the server in Form data, but it doesn’t?
What I do see is a header hx-active-element-value containing the “abc” value.
chg20 replied:
Yeah, buttons are a little tricky The way that forms work is that on submit they will include the clicked button value, but that is hard to do consistently from a dynamic ajax context … to complete the thought: since I didn’t feel I could consistently provide the value for buttons in all expected contexts, I chose to provide the active element (the usual hack work around for this button problem) as exactly that: the active element, so that there is truth in advertising.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)

Top Related StackOverflow Question
Couldn’t we exclude all buttons except for the one that triggered the event?
in the next release we will include the value of the clicked button in forms