create resource with another resource as a field
In the create form how can I add an input that is another resource
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:
----------------------
To create a resource with another resource as a field in a create form using Refine, you can use the
useSelect
or useAutocomplete
hooks to fetch and display the related resource data. Below are examples using different UI frameworks supported by Refine.
Using Ant Design
For Ant Design, you can use the useSelect
hook to create a select input for the related resource. Here is an example:
Source (https://refine.dev/docs/guides-concepts/forms/#relationships-)
Using Material UI
For Material UI, you can use the useAutocomplete
hook to create an autocomplete input for the related resource. Here is an example:
Source (https://refine.dev/docs/ui-integrations/material-ui/hooks/use-auto-complete/#how-do-i-use-it-with-crud-components-and-useform)
Using Mantine
For Mantine, you can use the useSelect
hook similarly to how it's used with Ant Design. Here is an example:
```tsx
import React
----------------------
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