Determine checkbox group inside array by appended object #10987
Unanswered
marilavoura
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
On version 7.30.0 it has been added support for determining checkbox group based on defaultValues (#7938).
However, when the field that represents the checkbox group with only one checkbox is inside an array, that is empty in defaultValues, the solution provided is not working. Is there a way to also check appended values?
For example:
const { register, handleSubmit, control, watch } = useForm({ defaultValues: { array: [], } });
const { append } = useFieldArray({ name: "array", control });
append({ checkbox: [] })
The expected behavior was the checkbox to be unchecked, as the checkbox was initally seted as an empty array in append.
Here is a sandbox that reproduces the issue:
https://codesandbox.io/s/register-forked-tlflhj?file=/src/App.js
Beta Was this translation helpful? Give feedback.
All reactions