useFieldArray with a required radio group #10234
Unanswered
ThomasRutzer
asked this question in
Q&A
Replies: 3 comments
-
I think you just need to give the same name for all the https://codesandbox.io/s/field-array-with-required-radio-group-9w2kc9?file=/src/App.tsx |
Beta Was this translation helpful? Give feedback.
0 replies
-
@ThomasRutzer have you ever found a solution? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Any Updates |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am having a list with the following FormData:
{ name: string; isSelected: boolean }[]
Now, I want to make use of
useFieldArray
, but with this requirements:isSelected
is rendered as a radio input. The radios should behave like a radio group, i.e. only one can be selected (this is usually accomplished by a similar "name" attribute of all radios)required
rule so that exactly one radio must be selected by the userI have prepared a Codesandbox and hope somebody can help me achieving this.
There is also this note in the official docs, maybe someone has a pointer / example for that:
Each input name needs to be unique, if you need to build checkbox or radio with the same name then use it with useController or controller.
Beta Was this translation helpful? Give feedback.
All reactions