Save and return to listing

Hi all, Wondering if its possible to have a save button that redirects to the listing page after saving? I've tried using
protected function getFormActions(): array
{
return [
$this->getSaveFormAction()
->submit('save'),

$this->getCancelFormAction()

];
}
protected function getFormActions(): array
{
return [
$this->getSaveFormAction()
->submit('save'),

$this->getCancelFormAction()

];
}
But cant find a way of redirecting after the save, I've also tried
->alpineClickHandler()
->alpineClickHandler()
but that redirects before the form is saved
Solution:
Was able to get it to work using ``` protected function getFormActions(): array { return [ $this->getSaveFormAction()...
Jump to solution
3 Replies
garethfrost
garethfrostOP7d ago
Sorry forgot to say in the description that there needs to be 2 save buttons, 1 to just save and 1 to save and redirect
Solution
garethfrost
garethfrost2d ago
Was able to get it to work using
protected function getFormActions(): array
{
return [
$this->getSaveFormAction()
->label('Save'),

Actions\Action::make('save_submit')
->label('Save & Submit')
->action(function () {
$this->save();
return redirect()->to(QualificationResource::getUrl('index'));
}),

$this->getCancelFormAction()
];
}
protected function getFormActions(): array
{
return [
$this->getSaveFormAction()
->label('Save'),

Actions\Action::make('save_submit')
->label('Save & Submit')
->action(function () {
$this->save();
return redirect()->to(QualificationResource::getUrl('index'));
}),

$this->getCancelFormAction()
];
}

Did you find this page helpful?