Forwarding to an url after action is finished
Is it possible to redirect to for example the index page after an action has finished?
I wanted to refresh the whole form (this way some fields will become not editable). The above setup doesn't work.
So I thought maybe it's possible to redirect to the index page after the order has been sent. Any suggestions?
18 Replies
Thanks for your reply.
I tried this:
but I got: Route [orders.list] not defined.
I have this list of routes defined in my orderResource:
But I get that the route is not defined.
I have tried:
and
As well.
Try
OrderResource::getUrl()
Thanks that returns the right url. But the redirect doesn't work.
Nothing happends it just stays on the same page.
Probably because its not getting called
You probably need to redirect yourself in the action
Something like:
i dont know if this helps but did this to redirect after a confirmation action
https://discord.com/channels/883083792112300104/1202209539848413204
So when I do this
I get a big error that the route is not defined. But when I copy / paste the route from the error and add it in my url bar it just works
Did you import the OrderResource?
And check the routes in the OrderResource.
Yes:
These are my routes
->action(function (Order $order){
SendOrder::dispatch($order);
Notification::make()
->success()
->title('Order verwerkt');
return redirect(OrderResource::getUrl('index'));
})
Yea, so
App\Filament\Resources\OrderResource::getUrl()
should work.
Also, you don't have to use 'index' since thats default on getUrl()
.
Same error
What is the error.
what is errro?
lol sorry @CodeWithDennis !
I had tho remove the
redirect()
so then it worked.
Question remains: what is this method for: successRedirectUrl(route('index'))
Thanks for your helpThats odd..
successRedirectUrl
is for saving / creating i think.I hit the same issue befor with notifications etc happening before the redirect - thats how i got around it
successRedirect is just on Save/Create as CodewithDennis says