Open jaredpalmer opened 5 years ago
In the array-bound checkbox group, what would happen if I put a value
prop on the <Field>
?
// Sibling labels => { values: { jobTypes: ["remote", "fulltime"] } }
<Field type="checkbox" id="remove-checkbox" value="remove" name="jobTypes" />
<label htmlFor="remote">Remote</label>
<Field type="checkbox" id="fulltime-checkbox" value="fulltime" name="jobTypes" />
<label htmlFor="fulltime">Remote</label>
Should value
take precedence over the id
? I've run into this same problem while building some custom components for my teammates, and I've just kept putting off array checkboxes.
Good catch. name
and value
is required for the array bound checkbox and id
is just for a11y. I updated my example
We should be consistent. The nice thing about using
id
is that you can stay DRY (and accessible) for a lot of inputs. I think thatuseField
/Field
should support both, withname
taking precedence overid
if both are specified. Below are some examples/cases (not exhaustive) to think about during this conversation.Basic Examples
Other cases
Checkboxes
Based on the new behavior proposed in #1555
Boolean
Array-bound to checkbox group