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
𝓑𝓾𝓼𝓽𝔂 𝓝π“ͺ𝓲𝓡
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');
}
𝓑𝓾𝓼𝓽𝔂 𝓝π“ͺ𝓲𝓡
oh see now ure using v2.. this solution is for v3, but maybe it works also in v2
UrbanizedSpy
UrbanizedSpyOPβ€’2y ago
Thanks, that still worked for me!

Did you find this page helpful?