getRedirectUrl() not works - how to use it?
Straight from documentation:
Customizing redirects
By default, saving the form will not redirect the user to another page.
You may set up a custom redirect when the form is saved by overriding the getRedirectUrl() method on the Edit page class.
For example, the form can redirect back to the List page of the resource:
However this does not appear to be true or i am not doing it well.
Despite that it is very very unclear where to put/use code snippets in Filament documentation (unlike laravel docs, where you can cleary understand what is the file document is reffering too), i guessed that above snippet i shall place in resource.
What i see is that getResource() method is not recognisible, and as result, when i save Resource, i am not redirected to index.
Here is the photo of implementation , so clearly to see that method does not exists.
Solution:Jump to solution
You may set up a custom redirect when the form is saved by overriding the getRedirectUrl() method on the Create page class.I think you are supposed to set that on the EditExpense and/or CreateExpense class as opposed to the ExpenseResource itself, if that makes sense. 🤔...
2 Replies
Solution
You may set up a custom redirect when the form is saved by overriding the getRedirectUrl() method on the Create page class.I think you are supposed to set that on the EditExpense and/or CreateExpense class as opposed to the ExpenseResource itself, if that makes sense. 🤔
Yup. That caught me at the start as well.
It needs to be added to the Edit and/or create page as needed. Not the base resource.
Same way header actions (top right) need to be added to their relevant pages, not the base resource.