Replies: 1 comment 3 replies
-
Of course, you can set the boolean value of the checkbox field. export default function Form() {
const { register, handleSubmit, control } = useForm({
defaultValues: {
enabled: false,
},
});
const onSubmit = (data) => console.log(data);
const enabled = useWatch({ name: "enabled", control });
console.log({ enabled, type: typeof enabled });
return (
<form onSubmit={handleSubmit(onSubmit)}>
<div className="checkbox">
<input type="checkbox" {...register("enabled")} />
<label>label</label>
</div>
<input type="submit" />
</form>
);
} |
Beta Was this translation helpful? Give feedback.
3 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
It is as simple as: the following code doesn't work with a regular boolean field:
I really wished this was covered in the register doc page.
Beta Was this translation helpful? Give feedback.
All reactions