eastern-cyan
eastern-cyan6mo ago

how to handle return data before filling form in useDrawerForm?

how to handle return data before filling form in useDrawerForm?
2 Replies
kapa.ai
kapa.ai6mo ago
Hi @hoaanhtuc. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In the useDrawerForm hook, you can handle the return data before filling the form by using the show function. This function opens the <Drawer> and takes an optional id parameter. If id is provided, it will fetch the record data and fill the <Form> with it. Here is an example of how you can use the show function:
const { show } = useDrawerForm({
action: "edit",
});

<Button onClick={() => show("1")}>Edit Record</Button>
const { show } = useDrawerForm({
action: "edit",
});

<Button onClick={() => show("1")}>Edit Record</Button>
In this example, when the button is clicked, the show function is called with the id of the record to be edited. This will fetch the data for that record and fill the form with it. For more information, you can refer to the useDrawerForm documentation (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-drawer-form#show). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@617879699363725341> kapa.ai is still learning and improving, please let us know how it did by reacting below