Pass form prop to input so it works even if the select is ouside the form tag
Hello!
When using CreatableSelect outside of a form passing it a form prop, this prop is not passed to the created input resulting in the field not being submitted as part of the form.
This PR fixes it.
My problem was with CreatableSelect but it might fix other use cases as well.
🦋 Changeset detected
Latest commit: 0e43b00ce644ddf45bad8cc78124c2a20ec7a8d9
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| react-select | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 0e43b00ce644ddf45bad8cc78124c2a20ec7a8d9:
| Sandbox | Source |
|---|---|
| react-codesandboxer-example | Configuration |
Using a regular select will submit the myField value.
<div>
<form action="/someAction" id="myForm">
<input type="submit" />
</form>
<select form="myForm" name="myField">
<option value="x">X</option>
<option value="y">Y</option>
</select>
<div>
Using React-Select, it won't.
<div>
<form action="/someAction" id="myForm">
<input type="submit" />
</form>
<Select form="myForm" name="myField" options={[{ value:"x", label: "X" }, { value:"y", label: "Y" }]} />
<div>
This PR fixes it.