Change CreateRecord cancel link

Hi all - I'm on Filament 2 and it looks like the cancel button on a CreateRecord goes back to the previous URL but I'd like it to go back to the index. Is it possible to change this link?
Solution:
Add this to your xxxResource/Pages/CreateXXX.php ```php use Filament\Actions\Action; ...
Jump to solution
3 Replies
Solution
RustyNail
RustyNail15mo ago
Add this to your xxxResource/Pages/CreateXXX.php
use Filament\Actions\Action;

protected function getCancelFormAction(): Action
{
return Action::make('cancel')
->label(__('filament-panels::resources/pages/edit-record.form.actions.cancel.label'))
->url(url('/admin')) // edit /admin with where it should be redirected.
->color('gray');
}
use Filament\Actions\Action;

protected function getCancelFormAction(): Action
{
return Action::make('cancel')
->label(__('filament-panels::resources/pages/edit-record.form.actions.cancel.label'))
->url(url('/admin')) // edit /admin with where it should be redirected.
->color('gray');
}
RustyNail
RustyNail15mo ago
oh see now ure using v2.. this solution is for v3, but maybe it works also in v2
UrbanizedSpy
UrbanizedSpyOP15mo ago
Thanks, that still worked for me!
Want results from more Discord servers?
Add your server