How to redirect to different resource list on useModalForm
Let say i am using using useModalForm() and define resource "a" for that. But after submited i want it redirect to resource "b" list page. Help me to achieve that.
7 Replies
Hi @M Farhan Zachary. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the provided knowledge sources do not contain specific information about redirecting to a different resource list using
useModalForm()
in Refine. However, they do provide information about redirection using the useForm()
hook.
In useForm()
, you can control the redirection behavior after form submission by using the redirect
function or setting the redirect
property in the hook's options. By default, it redirects to the list
page, but you can programmatically specify a different destination. Here's an example:
In this example, after a successful mutation, the form redirects to the show
page. You can replace "show"
with the desired destination.
For more specific information about useModalForm()
, I recommend checking the official Refine documentation or the source code of the useModalForm()
hook.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@757407865391808603> kapa.ai is still learning and improving, please let us know how it did by reacting below
genetic-orange•6mo ago
please show me full example of form to redirect to different resource after submited @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
I'm sorry, but the provided knowledge sources do not contain a full example of a form that redirects to a different resource after being submitted. However, they do provide information about redirection using the
useForm()
hook.
Here's an example of how you can use the redirect
function in useForm()
to programmatically specify a different destination after a successful mutation:
In this example, after a successful mutation, the form redirects to the show
page. You can replace "show"
with the desired destination.
For more specific information about redirecting to a different resource, I recommend checking the official Refine documentation or the source code of the useForm()
hook.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@757407865391808603> kapa.ai is still learning and improving, please let us know how it did by reacting below
optimistic-gold•6mo ago
Hey @M Farhan Zachary you can use
useGo
hook in onMutationSuccess
after setting redirect: false
in your hook.
https://refine.dev/docs/routing/hooks/use-go/#usageuseGo | Refine
useGo is a hook that leverages the go method of the routerProvider to perform navigation operations.
genetic-orange•6mo ago
thanks, i dont know that