Skip to content

fix: include submit button name/value when button owns hx-post - #4082

Merged
1cg merged 2 commits into
bigskysoftware:four-devfrom
MichaelWest22:button-value-submit
Sep 17, 2026
Merged

1cg merged 2 commits into
bigskysoftware:four-devfrom
MichaelWest22:button-value-submit

Conversation

@MichaelWest22

@MichaelWest22 MichaelWest22 commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Description

fix: include submit button name/value when button owns hx-post (#4073)

In htmx 4, __collectFormData relied solely on evt.submitter to append a submit
button's name/value. This is null on a click event — only a native form submit
populates it — so buttons with hx-post directly on them never sent their own
name/value.

Fix: if submitter is not set and elt is itself a named submit button inside a
form, treat elt as the submitter.

submitter ??= (form && elt.type === 'submit') ? elt : null;

This restores the htmx 1.x/2.x behaviour where a submit button's name/value is
always included in the request body.

Corresponding issue:
#4073

Testing

Added tests for various cases

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

@MichaelWest22 MichaelWest22 added bug Something isn't working htmx 4 Issues specific to htmx version 4 labels Sep 16, 2026
@1cg
1cg merged commit 07787a1 into bigskysoftware:four-dev Sep 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working htmx 4 Issues specific to htmx version 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants