Skip to content

Bug: Form submitter is missing, if form includes input with name 'id' #34944

@torjusb

Description

@torjusb

When creating a form, with multiple submit buttons, you can tell which button is the submitter by giving the button a name and value. But if you include an input element with the name id within the form, like <input type="hidden" name="id" value="1" /> this information is gone.

The issue seems to originate from the function createFormDataWithSubmitter() in React. Specifically where it checks for form.id.

if (form.id) {
temp.setAttribute('form', form.id);
}

When you include an input element with the name id, form.id will be the actual input element. I guess the intention here is instead to get the id attribute on the form instead?

<form id="my-form">
  <input type="hidden" name="id" value="1" />
</form>

In the above example, form.id will be the <input /> element, not my-form. If I remove the input element, form.id will be my-form.

React version: 19.2

Steps To Reproduce

  1. Create a form with with a named submit button (e.g. action, and an input field with name id
  2. Call formData.get('action') within the action handler of the form

Link to code example: https://codesandbox.io/p/sandbox/naughty-dew-d39gvp?file=%2Fsrc%2FApp.js%3A16%2C16

The current behavior

The return value of formData.get('action') is null

The expected behavior

The return value should be the value of the submitter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions