quickest-silver
quickest-silver2mo ago

How to get values of form before submit in useStepForm?

How to get values of form before submit in useStepForm?
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @tingadev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To get the values of the form before submitting in useStepsForm, you can use the submit property of the hook to override the default submit behavior. This allows you to access and modify the form values before they are sent to the API. Here's how you can do it:
const {
// ... other properties
submit
} = useStepsForm({
submit: (values) => {
console.log(values); // Here you can access the form values
// Modify the values if needed
const modifiedValues = {
...values,
// Add or modify fields as necessary
};
// Call onFinish with the modified values
onFinish(modifiedValues);
},
});
const {
// ... other properties
submit
} = useStepsForm({
submit: (values) => {
console.log(values); // Here you can access the form values
// Modify the values if needed
const modifiedValues = {
...values,
// Add or modify fields as necessary
};
// Call onFinish with the modified values
onFinish(modifiedValues);
},
});
In this example, the submit function receives the form values as an argument. You can then access these values, modify them if needed, and then call onFinish with the final values you want to submit. This approach is documented in the useStepsForm FAQ (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-steps-form/#faq) for the Ant Design integration. The same principle applies to other UI integrations as well. If you need to perform more complex operations or validations before submitting, you can expand on this pattern to include additional logic within the submit function. Remember that the exact implementation might vary slightly depending on the UI framework you're using with refine (Ant Design, Mantine, etc.), but the core concept remains the same. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@761921731505946634> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?