htmx
htmx copied to clipboard
Submit button values are not sent
On a simple form, the name and value of a <button type="submit"> button are not sent.
<form>
<input type="text" name="text-field" value="input OK">
<button type="submit" name="submit-button" value="foobar" hx-target="#results"
hx-post="/echo/json">button KO</button>
</form>
<code id="results"></code>
You can check this fiddle, and inspect the requests to observe this behavior: https://jsfiddle.net/azmeuk/7ztxd820/54/
Using hx-include on the button does not send the data either so it cannot be used as a workaround, but I could manage to achieve what I want with hx-vals.
Might be related to #970 #971 #1120 #1337
Submitted a PR that addresses this issue.
In the meantime, for current & older versions, even though it may not be what you want, it turns out that putting the hx-post (and hx-trigger) on the form itself, correctly includes the clicked button's value, if of course such workaround is possible in your situation
Fixed since 1.9.4 Thank you!