extended-salmon
extended-salmon5mo ago

how to manipulate data for stepForm ant d

how to manipulate data for stepForm ant d before calling api
2 Replies
kapa.ai
kapa.ai5mo ago
Hi @jash.s. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To manipulate data in a useStepsForm with Ant Design before submitting it to the API in a Refine application, you can override the submit function within the useStepsForm hook. This allows you to modify the form data as needed. For example, if you need to combine the values of two separate inputs, name and surname, into a single fullName field before sending it to the API, you can do so as follows:
import { useStepsForm } from "@refinedev/antd";
// ...
const { current, gotoStep, stepsProps, formProps, saveButtonProps, onFinish } = useStepsForm<IPost>({
submit: (values) => {
const data = {
fullName: `${values.name} ${values.surname}`,
age: values.age,
city: values.city,
};
onFinish(data as any);
},
});
// ...
import { useStepsForm } from "@refinedev/antd";
// ...
const { current, gotoStep, stepsProps, formProps, saveButtonProps, onFinish } = useStepsForm<IPost>({
submit: (values) => {
const data = {
fullName: `${values.name} ${values.surname}`,
age: values.age,
city: values.city,
};
onFinish(data as any);
},
});
// ...
In this example, the submit function is overridden to combine name and surname into fullName, along with other fields like age and city, before calling the onFinish method with the modified data. For more detailed information, you can refer to the documentation on how to change the form data before submitting it to the API using useStepsForm in Refine with Ant Design: useStepsForm - How can I change the form data before submitting it to the API? (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-steps-form#how-can-i-change-the-form-data-before-submitting-it-to-the-api) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@1129363768661516329> kapa.ai is still learning and improving, please let us know how it did by reacting below