extended-salmon
extended-salmon•3y ago

Nested

I am trying to add nested resources, List inside Show (for one-to-many) also have a create in list using drawerform, but drawer form is catching the context of show not the List
27 Replies
Omer
Omer•3y ago
Hey @bhk2988 , Sorry, I don't fully understand. Can you give some example?
fair-rose
fair-rose•3y ago
No description
fair-rose
fair-rose•3y ago
I am creating something like this DIstribution -> has many versions I wan to add version to that distribution directly from here But when I click on create
fair-rose
fair-rose•3y ago
No description
fair-rose
fair-rose•3y ago
It is showing Distribution and not version
Omer
Omer•3y ago
You can use "resource" and "action" properties of useDrawerForm and can access active distribution id from id property of useShow
Omer
Omer•3y ago
As in this example, you can add the distributionId to your form data by overrriding the onFinish property of useDrawerForm. https://refine.dev/docs/guides-and-concepts/upload/base64-upload/
Base64 Upload | refine
By encoding your files and images from your forms to Base64 you can change all files needed for the upload to Base64 format before the submit. This can be done via the onFinish property of the `` component that comes with Ant Design
Omer
Omer•3y ago
Also you can override Create component' resource, title, etc properties. https://refine.dev/docs/ui-frameworks/antd/components/basic-views/create/#resource
Create | refine
`` provides us a layout to display the page. It does not contain any logic but adds extra functionalities like action buttons and giving titles to the page.
fair-rose
fair-rose•3y ago
I have passed resource to create
No description
fair-rose
fair-rose•3y ago
But it still showing clone their I hv managed to remove it by setting tags property of page header to empty array but still this should be the default behavior?
Omer
Omer•3y ago
Uhmm looks like a bug. Could you create a issue?
fair-rose
fair-rose•3y ago
Sure Also can u tell how we can manage redirect ? as there is no page component for this
Omer
Omer•3y ago
You can use useNavigation hooks
Omer
Omer•3y ago
useNavigation | refine
refine uses routerProvider and comes with all redirects out of the box. It allows you to manage your routing operations in refine. Using this hook, you can manage all the routing operations of your application very easily.
fair-rose
fair-rose•3y ago
After form is submited API is hit and its redirected to "list" of the resource by default but what if I want to stop the redirection
Omer
Omer•3y ago
You can set the redirect parameter of useForm as "false"
fair-rose
fair-rose•3y ago
I am using useDrawerForm it doesn't have "false"
Omer
Omer•3y ago
Hey, are you sure?
const {
....
} = useDrawerForm({
action: "create",
redirect: false
});
const {
....
} = useDrawerForm({
action: "create",
redirect: false
});
https://codesandbox.io/s/refine-use-drawer-form-example-forked-95bpls?file=/src/pages/posts/list.tsx:742-762
fair-rose
fair-rose•3y ago
useDrawerForm | refine
useDrawerForm hook allows you to manage a form within a Drawer. It returns Ant Design Form and Drawer components props.
fair-rose
fair-rose•3y ago
redirect has only show edit list
Omer
Omer•3y ago
hmm i guess it was forgotten 🙂 Thanks for your attention. Do you want to update the document? or can we update it? You can see it in its version in "core", https://refine.dev/docs/core/hooks/useForm/#properties
fair-rose
fair-rose•3y ago
It's also absent in the type defination Will raise a pull request for this
Omer
Omer•3y ago
Thank you @bhk2988 🚀
fair-rose
fair-rose•3y ago
GitHub
docs: added false type to redirect property of usedrawerform, usemo...
Added missing false type to redirect property of useDrawerForm, useModalForm, useStepsForm.
Omer
Omer•3y ago
Wow thank you! Could you update on v3 docs too?
fair-rose
fair-rose•3y ago
Is there any way we can hook on success? Caz I want to re fetch data after adding
Omer
Omer•3y ago
Yes, you can use "onMutationSuccess"