Intercept Before Create

Hello! I need to manipulate some form data before sending to the server, there's and hook/middleware/action to intercepet the form action and act before? Thanks!
H
harsh-harlequin516d ago
Hi @fatrex, Do you you use @pankod/refine-react-hook-form ? if you, u can use this example: https://stackblitz.com/edit/refinedev-refine-cutjm6?file=src/pages/posts/create.tsx
const onSubmitHandler: SubmitHandler<any> = (data) => {
console.log(data);
// data manipulations
return onFinish(data);
};

// ---

<form onSubmit={handleSubmit(onSubmitHandler)}>
const onSubmitHandler: SubmitHandler<any> = (data) => {
console.log(data);
// data manipulations
return onFinish(data);
};

// ---

<form onSubmit={handleSubmit(onSubmitHandler)}>
W
wise-white516d ago
Thanks @alicanerdurmaz ! Sorry I forgot to mention that actualluy I'm using useForm from antd. Maybe there's something similat
H
harsh-harlequin516d ago
It's very similar 🙏
const onSubmitHandler = (data: any) => {
console.log(data);
// data manipulations

return formProps.onFinish?.(data);
};

// ****

<Form {...formProps} onFinish={onSubmitHandler} layout="vertical">
const onSubmitHandler = (data: any) => {
console.log(data);
// data manipulations

return formProps.onFinish?.(data);
};

// ****

<Form {...formProps} onFinish={onSubmitHandler} layout="vertical">
https://stackblitz.com/edit/refinedev-refine-tq7rwx?file=src/pages/posts/create.tsx
W
wise-white516d ago
onFinish ! Thanks 😄