Custom action redirect

Hello, what would be the cleanest way to setup a redirect inside a custom action on Edit page. I'd like to redirect back to index page of my resource but this https://filamentphp.com/docs/2.x/admin/resources/editing-records#customizing-form-redirects does not for me with my custom action. Works fine with Save button but not my custom button
10 Replies
toeknee
toeknee17mo ago
Custom action did you try a return redirect('path') ?
ralphredd
ralphreddOP17mo ago
I did, but I was looking for a way to do it more "Filament-y" way
toeknee
toeknee17mo ago
I don't believe there is for a form, since you handle it. You can use the REsource::getURL('index'); to get the resouce url
ralphredd
ralphreddOP17mo ago
That didn't work work me: Route [filament.resources..index] not defined. Not sure why since this is working just fine for me: redirect()->route('filament.resources.events.index')
toeknee
toeknee17mo ago
What did you try for the exact code? as [filament.resources..index] has an extra dot.
ralphredd
ralphreddOP17mo ago
Yeah, I saw that too. Not sure where the double dot comes from
toeknee
toeknee17mo ago
Resource ?!? You need to replace that with the resource Class.. So: EventsResource::getUrl('index')
ralphredd
ralphreddOP17mo ago
Ahhh, that's what I've missed. Sorry, started using Filament 4 days ago 😦 Works perfect now
toeknee
toeknee17mo ago
No problem
ralphredd
ralphreddOP17mo ago
and Thank you!
Want results from more Discord servers?
Add your server