bigskysoftware / bigskysoftware/htmx

Regression in 4.0.0: submit button name/value not sent

Open
#4,073 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

A named `` carrying its own `hx-post` inside a `` doesn't send its own `name`/`value` in 4.0.0. No console warning, no error, the parameter just never reaches the server, so the symptom is "the button does nothing" in an app that worked under htmx 2.

This is what #1506 reported on 1.x. It was fixed by #1559 and shipped in 1.9.4. I get the button value on 1.9.4, 1.9.12 and 2.0.10, and I don't on 4.0.0-beta3, 4.0.0-beta4 or 4.0.0. alpha1 and beta1 aren't on the CDN anymore, so beta3 is as far back as I could check.

The docs still say, under Forms - Input Values: "By default, an element that causes a request will include its `value` if it has one."

Repro, no server needed, it intercepts the request and prints the body htmx built:

```html


click me

click the button

document.body.addEventListener("htmx:config:request", (evt) => {
const body = evt.detail.ctx.request.body;
document.getElementById("out").textContent =
[...body.entries()].map(([k, v]) => `${k}=${v}`).join("\n") || "(empty)";
evt.preventDefault();
});

```

On 4.0.0 that prints `txt=hello`. On 1.9.4 through 2.0.10 it prints `txt=hello` and `btn=B`.

Two variations in case they help narrow it down: removing the `` wrapper makes 4.0.0 include `btn=B`, and adding `hx-include="closest form"` to the button changes nothing. #1506 reported the same about `hx-include`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.