F
Filamentβ€’16mo ago
Tin

How to redirect to edit page from create modal?

I want to redirect to edit page when I create the record in the modal. Thanks
6 Replies
LeandroFerreira
LeandroFerreiraβ€’16mo ago
->after() ?
Tin
Tinβ€’16mo ago
Yeah but how to get the id. $model/$record does not resolve I can get the last record and redirect but i think there shouls be an easier way. It's late and I thought I'd ask here before investigating by myself
LeandroFerreira
LeandroFerreiraβ€’16mo ago
yes, the id is the problem... maybe
public $record;

protected function getActions(): array
{
return [
Actions\CreateAction::make()
->action(function ($data) {
$this->record = Model::create($data);
})
->after(function () {
$this->mountTableAction('edit', $this->record->id);
}),
];
}
public $record;

protected function getActions(): array
{
return [
Actions\CreateAction::make()
->action(function ($data) {
$this->record = Model::create($data);
})
->after(function () {
$this->mountTableAction('edit', $this->record->id);
}),
];
}
Tin
Tinβ€’16mo ago
I guess custom solution it is then πŸ˜…
LeandroFerreira
LeandroFerreiraβ€’16mo ago
yes haha.. it could be better, but you can try
Tin
Tinβ€’16mo ago
Yeah, thanks anyways πŸ™‚