8 Replies
Hi @tads8799. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In refine, you can control the redirection behavior after a form is submitted using the
redirect
property in the useForm
hook. By default, it redirects to the list
page. However, you can set it to "show"
, "edit"
, "list"
, "create"
, or false
to prevent the page from redirecting to the list page after the form is submitted.
Here's an example of how to use it:
In this example, redirect
is set to false
, which means the page will not redirect after the form is submitted. If you want to go back to the list page after edit or create, you can set redirect
to "list"
.
This will ensure that after a record is created or edited, the application will redirect to the list page.
Sources:
- Refine Documentation - useForm (https://refine.dev/docs/packages/documentation/react-hook-form/useForm/)
- Refine Documentation - Save and Continue (https://refine.dev/docs/advanced-tutorials/forms/save-and-continue/)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below
genetic-orange•13mo ago
By default, it redirects to the list page. Why mine is disabled? @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
In your code, you haven't specified the
redirect
property in the useForm
hook. By default, refine redirects to the list
page of the resource after a successful form mutation. However, if you have set the redirect
property to false
somewhere else in your code, it will prevent the page from redirecting to the list page after the form is submitted.
Here's how you can enable redirection to the list page:
In this example, redirect
is set to "list"
, which means the page will redirect to the list page after the form is submitted.
If the redirection is still not working, it might be due to other parts of your code or a configuration in the <Refine>
component. For example, if you have set afterEdit
or afterCreate
to false
in the redirect
option of the <Refine>
component, no redirect will be performed after a successful form mutation.
Please check your code and configuration to ensure they are set correctly.
Sources:
- Refine Documentation - useForm (https://refine.dev/docs/packages/documentation/react-hook-form/useForm/)
- Refine Documentation - Refine Config (https://refine.dev/docs/api-reference/core/components/refine-config/)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below
genetic-orange•13mo ago
I don't set the redirect property to false anywhere else. I dont set or to false in the redirect option of the component either @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
If you haven't set the
redirect
property to false
anywhere in your code and you haven't set afterEdit
or afterCreate
to false
in the redirect
option of the <Refine>
component, then the default behavior should be to redirect to the list
page after a successful form mutation.
However, if the redirection is not happening as expected, it might be due to other factors. Here are a few things you can check:
1. Mutation Modes: In undoable
and optimistic
mutation modes, the redirect happens before the mutation succeeds. Therefore, if there is no data in the query cache, the user will be redirected to the list page.
2. Show Page: If you don't have a show page and you redirect to the show page, the user will be redirected to the list page.
3. Form Submission: Ensure that the form is being submitted successfully. If there are any errors in the form submission or the mutation, the redirect might not happen.
4. Resource Name: Check the resource name in the useForm
hook. It should match the resource name defined in your API.
If you've checked all of these and the issue persists, it might be a bug or a more complex issue. In that case, you might want to reach out to the refine community or support for more help.
Sources:
- Refine Documentation - useForm (https://refine.dev/docs/packages/documentation/react-hook-form/useForm/)
- Refine Documentation - Refine Config (https://refine.dev/docs/api-reference/core/components/refine-config/)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@577213996344803338> kapa.ai is still learning and improving, please let us know how it did by reacting below