Closed jacobsamo closed 9 months ago
Describe the bug When using drizzle-zod to generate schemas from database schemas and using them in the useForm resolvers the onSubmit won't fire at all for some reason,
drizzle-zod
useForm
So for example:
export const userSchema = createInsertSchema(users);
and then using it in the useForm
const { handleSubmit, register, control, getValues } = useForm<User>({ resolver: zodResolver(userSchema), defaultValues: async () => { const res = await fetch(`/api/users/`) const user = (await res.json()) as User; return user; }, }); const onSubmit: SubmitHandler<User> = async (data) => { console.log(data) await fetch('/api/users/updateUser', { method: "PUT", body: body: JSON.stringify(data), }) };
in this example when you click the Submit from the form it doesn't work at all.
Submit
however if you build your own schema using zod it works fine.
For reference this was working about a about a week ago.
No errors show in the browser console or terminal, so i don't know what is up there
To Reproduce Steps to reproduce the behavior:
createInsertSchema
try submitting the form (should not work)
Codesandbox link (Required) very simple application that doesn't seem to submit: https://codesandbox.io/p/sandbox/react-hook-form-zod-resolver-not-working-9c7qn9
Expected behavior I expected that validation would work out of the box as usual
Desktop (please complete the following information):
Additional context
References:
Describe the bug When using
drizzle-zod
to generate schemas from database schemas and using them in theuseForm
resolvers the onSubmit won't fire at all for some reason,So for example:
and then using it in the
useForm
in this example when you click the
Submit
from the form it doesn't work at all.however if you build your own schema using zod it works fine.
For reference this was working about a about a week ago.
No errors show in the browser console or terminal, so i don't know what is up there
To Reproduce Steps to reproduce the behavior:
drizzle-zod
andcreateInsertSchema
useForm
resolvertry submitting the form (should not work)
Codesandbox link (Required) very simple application that doesn't seem to submit: https://codesandbox.io/p/sandbox/react-hook-form-zod-resolver-not-working-9c7qn9
Expected behavior I expected that validation would work out of the box as usual
Desktop (please complete the following information):
Additional context
References: