eastern-cyan
eastern-cyan12mo ago

Create Resource from another Resource in List View

So I basically want to integrate a button "copy" into the list-view that will route to a new form of the given resource and copy fields from the resource I clicked on. @kapa.ai How would I do that?
2 Replies
kapa.ai
kapa.ai12mo ago
Hi @bastianwegge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- You can achieve this by using the CloneButton component provided by Refine. This button is designed to redirect the app to the clone action of the given resource name. When clicked, it triggers the clone method of useNavigation and then redirects the app to the clone action path of the resource, filling the necessary parameters in the route. Here is an example of how you can use it:
import { CloneButton } from "@refinedev/antd"; // Use the appropriate UI library

const MyCloneComponent = () => {
return <CloneButton resource="categories" recordItemId="1" />;
};
import { CloneButton } from "@refinedev/antd"; // Use the appropriate UI library

const MyCloneComponent = () => {
return <CloneButton resource="categories" recordItemId="1" />;
};
In this example, clicking the CloneButton will clone the resource with the recordItemId of "1" from the "categories" resource. You should replace "categories" and "1" with your resource name and the id of the record you want to clone, respectively. If you have multiple resources with the same name, you can pass the identifier instead of the name of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the name of the resource defined in the <Refine/> component. For more information, refer to the identifier section of the <Refine/> component documentation (https://refine.dev/docs/core/refine-component/#identifier) and the CloneButton documentation (https://refine.dev/docs/ui-integrations/ant-design/components/buttons/clone-button#resource). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai12mo ago
<@317433576721219584> kapa.ai is still learning and improving, please let us know how it did by reacting below