Are you submitting a bug report or a feature request?
Bug report
What is the current behavior?
Starting from final-form v4.20.3 and above, checkboxes with array field names (e.g. choices[]) started working unexpectedly, they used to work properly until v4.20.2.
When using [email protected]:
"final-form": "4.20.2",
"react-final-form": "^6.5.9",
The code below works as expected (v4.20.2 Codesandbox):
/* eslint-disable jsx-a11y/accessible-emoji */
import React from "react";
import { render } from "react-dom";
import { Form, useField } from "react-final-form";
const FinalFormCheckbox = ({ name, value, label }) => {
const renderProps = useField(name, {
type: "checkbox",
value
});
return (
<label>
<input name={name} type="checkbox" value={value} {...renderProps.input} />
<span>{label}</span>
</label>
);
};
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const onSubmit = async (values) => {
await sleep(300);
window.alert(JSON.stringify(values, 0, 2));
};
const App = () => (
<>
<h1>React Final Form - Checkbox Example - v4.20.2 - OK </h1>
<Form
onSubmit={onSubmit}
initialValues={{}}
render={({ handleSubmit, form, submitting, values }) => (
<form onSubmit={handleSubmit}>
<div>
<FinalFormCheckbox
name="choices[]"
value="choice_1"
label="Choice 1"
/>
<FinalFormCheckbox
name="choices[]"
value="choice_2"
label="Choice 2"
/>
<FinalFormCheckbox
name="choices[]"
value="choice_3"
label="Choice 3"
/>
</div>
<div className="buttons">
<button type="submit" disabled={submitting}>
Submit
</button>
<button type="button" onClick={form.reset} disabled={submitting}>
Reset
</button>
</div>
<pre>{JSON.stringify(values, 0, 2)}</pre>
</form>
)}
/>
</>
);
render(<App />, document.getElementById("root"));
If you check both Choice 2 and Choice 3 you get this shape of data for values:
{
"choices": [
"choice_2",
"choice_3"
]
}
Checkboxes appear to be checked:

final-form@^4.20.3, up to v4.20.7
On the other hand, when using [email protected] and above (e.g. v4.20.7):
"final-form": "^4.20.3",
"react-final-form": "^6.5.9",
The same code used above for v4.20.2 doesn't work as expected in version 4.20.3 and upwards:
If you check both Choice 2 and Choice 3 you get this wrong shape of data for values:
{
"choices": [
[
"choice_3"
]
]
}
Also, checkboxes remain in an unchecked state, despite having been checked:


What is the expected behavior?
v4.20.3 and above (e.g. v4.20.7) should behave consistently as version v4.20.2.
Sandbox Link
What's your environment?
Google Chrome
Are you submitting a bug report or a feature request?
Bug report
What is the current behavior?
Starting from
final-formv4.20.3and above, checkboxes with array field names (e.g.choices[]) started working unexpectedly, they used to work properly untilv4.20.2.[email protected]
When using
[email protected]:The code below works as expected (v4.20.2 Codesandbox):
If you check both
Choice 2andChoice 3you get this shape of data forvalues:{ "choices": [ "choice_2", "choice_3" ] }Checkboxes appear to be checked:
final-form@^4.20.3, up to v4.20.7
On the other hand, when using
[email protected]and above (e.g.v4.20.7):The same code used above for
v4.20.2doesn't work as expected in version4.20.3and upwards:If you check both
Choice 2andChoice 3you get this wrong shape of data forvalues:{ "choices": [ [ "choice_3" ] ] }Also, checkboxes remain in an unchecked state, despite having been checked:
What is the expected behavior?
v4.20.3and above (e.g.v4.20.7) should behave consistently as versionv4.20.2.Sandbox Link
What's your environment?
Google Chrome