form with child object
Do you have any examples of using a form where one of the fields is populated from anther resource / model
2 Replies
Hi @Pops / Spruce. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, there is an example in the Refine documentation where a form field is populated from another resource. In this case, a select field for "Category" is populated with options from a "categories" resource. Here is the relevant code:
In this example, the
useSelect
hook is used to fetch the options for the "Category" select field from the "categories" resource. The defaultValue
for the select field is set to the category id of the post being edited.
You can find more details in the Refine documentation (https://refine.dev/docs/packages/react-hook-form/use-form#usage).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@184452259327770625> kapa.ai is still learning and improving, please let us know how it did by reacting below