genetic-orange
genetic-orange•10mo ago

chakra ui form

Hi guys! I have a question, maybe a silly one but im not very experienced with react and just starting to learn refine. Is it possible using the inferencer generated page for create and save to change the data before submitting? I have found this link with related information https://refine.dev/docs/faq/#how-can-i-change-the-form-data-before-submitting-it-to-the-api but it works using a form and the inferencer for ChakraUI doesn't generate any form. Any idea? Thank you
FAQ | refine
How can I change the form data before submitting it to the API?
3 Replies
sensitive-blue
sensitive-blue•10mo ago
hello @fuzzball1980 you can copy inferenced code any modify according to your needs. you can add form element too
rising-crimson
rising-crimson•10mo ago
hi @alicanerdurmaz yes I know I Can modify the entire code but I want to take advantage of the inferencer generated code and touch it the minimun. I dont know how to access the default added buttons, and if I add another <form> I have to manually add the validations, the footer buttons, etc so it is basically start a crud from scratch. I believe there must be a way to extend the Edit, Create, List, Show components to access the features of the inferencer. but i dont know how to start 😫 oh! I found it in the documentation my bad! const onFinishHandler = (data: FieldValues) => { onFinish({ ...data, }); }; const { saveButtonProps, refineCore: { onFinish, formLoading, queryResult }, register, handleSubmit, resetField, formState: { errors }, } = useForm<HttpError>(); return (
<Create isLoading={formLoading} saveButtonProps={{ ...saveButtonProps, onClick: handleSubmit(onFinishHandler), }} > basically you can overwrite the onClick event on the saveButtonsProps thanks!
sensitive-blue
sensitive-blue•10mo ago
I'm glad to hear that. you can ask any question on #ask-any-question section