Replies: 4 comments 1 reply
-
you can always build a controlled component host your own local state as an array and wrapped with |
Beta Was this translation helpful? Give feedback.
-
I've had this same problem, and really wish there was a flag on register (something like {forceArray:true}. For now, I have hackily solved it by watching the value of the thing, and if it's a string, create an array and push the string into the array. Something like this:
|
Beta Was this translation helpful? Give feedback.
-
There is also another trick. |
Beta Was this translation helpful? Give feedback.
-
When I set the default values of the variable as an array, it always returns the values of the array. |
Beta Was this translation helpful? Give feedback.
-
I got a form with values:
Sometimes the form would only show a single checkbox (because there will only be one module to choose). The problem with that is that RHF doesn't give me
modules
as an array, but the value of that single checkbox.When there are multiple of checkboxes it always comes as an array upon submission. Can I somehow force RHF to always give me an array of the checked values?
I imagine I could like fake register an checkbox as well as register the single checkbox so that it always will be two registrered fields.
Otherwise I would have to change my type to this, but I prefer to always work with it as an array.
Beta Was this translation helpful? Give feedback.
All reactions