useModalForm 3.x.x add a value before server
const {
modalProps: createModalProps,
formProps: createFormProps,
show: createModalShow,
} = useModalForm<IManualAttendance>({
action: 'create',
resource: 'registers/manual-attendance',
redirect: false,
autoSubmitClose: true,
onMutationSuccess: (d) => {
fetchAttendanceTable(currentDate);
},
});
how do i add a value before the form sends on 3.x.x
2 Replies
Hi @royercross. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine 3.x.x, you can modify the form data before it is sent to the API by using the
onFinish
function in your form. Here's an example of how you can do this:
In this example, the onFinish
function is used to combine the name
and surname
fields into a fullName
field before the form data is submitted.
For more information, you can refer to the useForm documentation (https://refine.dev/docs/packages/documentation/react-hook-form/useForm/).
Please note that the code you provided seems to be using the useModalForm
hook, which is not covered in the provided extracts. The example I provided uses the useForm
hook. The approach might be slightly different with useModalForm
, but the general idea of using the onFinish
function to modify the form data should still apply.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@210531867777171456> kapa.ai is still learning and improving, please let us know how it did by reacting below