relaxed-coral
relaxed-coral2y ago

antd form.item

I have a form with 4 form items but i just want to post 3 items to table in hasura while submitting a form
5 Replies
like-gold
like-gold2y ago
Hi @rehan1, great to see you again 🙏 can you change data before submit ? you can filter out anything you want https://refine.dev/docs/faq/#how-can-i-change-the-form-data-before-submitting-it-to-the-api
FAQ | refine
How can I change the form data before submitting it to the API?
relaxed-coral
relaxed-coral2y ago
but iam using it in useModalForm how to pass that in okButtonProps
like-gold
like-gold2y ago
i will try to implement on useModalForm, please wait 🙏 can you follow this example snippet ? on form, u can ovveride onFinish() and manipluate returned data. after that u can call formProps.onFinish() with that data.
<Modal {...modalProps}>
<Form {...formProps}
onFinish={(values) => {
const { name, surname } = values;
const fullName = `${name} ${surname}`;

return (
formProps.onFinish &&
formProps.onFinish({
...values,
fullName,
})
);
}}
layout="vertical">
<Form.Item label="Title" name="title">
<Input />
</Form.Item>
<Form.Item label="Status" name="status">
<Radio.Group>
<Radio value="draft">Draft</Radio>
<Radio value="published">Published</Radio>
<Radio value="rejected">Rejected</Radio>
</Radio.Group>
</Form.Item>
</Form>
</Modal>
<Modal {...modalProps}>
<Form {...formProps}
onFinish={(values) => {
const { name, surname } = values;
const fullName = `${name} ${surname}`;

return (
formProps.onFinish &&
formProps.onFinish({
...values,
fullName,
})
);
}}
layout="vertical">
<Form.Item label="Title" name="title">
<Input />
</Form.Item>
<Form.Item label="Status" name="status">
<Radio.Group>
<Radio value="draft">Draft</Radio>
<Radio value="published">Published</Radio>
<Radio value="rejected">Rejected</Radio>
</Radio.Group>
</Form.Item>
</Form>
</Modal>
relaxed-coral
relaxed-coral2y ago
but i want to show formitem based on previous formitem which is select dropdown get selected? it worked thank u
like-gold
like-gold2y ago
Hi @rehan1 , sorry for late response. I'm glad to hear that 🙏