-
there is an Form example in docs here:
there is an error:
What should I do? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
I encountered the same issue, and I've submitted my PR to address it. You can find it here: GitHub PR. To resolve the problem, follow these steps: When utilizing <FormField
control={form.control}
name="picture"
render={({ field: { value, onChange, ...fieldProps } }) => (
<FormItem>
<FormLabel>Picture</FormLabel>
<FormControl>
<Input
{...fieldProps}
placeholder="Picture"
type="file"
accept="image/*, application/pdf"
onChange={(event) =>
onChange(event.target.files && event.target.files[0])
}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/> |
Beta Was this translation helpful? Give feedback.
-
i took this approach but server actions is causing error :
and if i serialize by doing this : const onSubmit = (values: z.infer<typeof OnBoardingSchema>) => {
setError("");
setSuccess("");
console.log(values);
const data = JSON.parse(JSON.stringify(values));
startTransition(() => {
onboarding(data).then((result) => {
setError(result.error);
setSuccess(result.success);
});
});
}; then image is empty as it is a complex object in the backend. I don't have any idea I'm new to it so please help |
Beta Was this translation helpful? Give feedback.
-
@harish-khandre using node 20x is ok on my PC |
Beta Was this translation helpful? Give feedback.
I encountered the same issue, and I've submitted my PR to address it. You can find it here: GitHub PR. To resolve the problem, follow these steps:
When utilizing
<Input type="file" />
alongside React Hook Form, it is important to have an uncontrolled input. You can achieve this by simply passing theonChange
handler to theonChange
prop of the input element.