urgent-maroonU
Refine•3y ago•
11 replies
urgent-maroon

How to add Zod validation to Create ressource page

Hi everyone! I'm using Refine with Next.js, MUI and a custom express API as a dataprovider. and I need help with Zod validation on CRUD pages.

I have a zod UserSchema which i'm passing to the useForm() like this

import { UserSchema } from "src/validation/user.validate";
import { zodResolver } from '@hookform/resolvers/zod';


const {
saveButtonProps,
refineCore: { formLoading, queryResult },
register,
control,
formState: { errors },
} = useForm({
resolver: zodResolver(UserSchema),

});

The validation is working fine but the save button no longer works. What should I do next? I tried adding an onClick to the saveButtonProps but that did not work.

I'm new to Refine and still learning 🙂
Was this page helpful?