Form action - save and load next record -

Is it possible to have a form action that saves the current and loads the next (filtered) record of a resource for editing?
Solution
override getFormActions() in the EditPage

protected function getFormActions(): array
{
    return [
        ...parent::getFormActions(),
        Actions\Action::make('saveAndNext')
            ->action(function () {

                $nextRecord = $this
                    ->getRecord()
                    ->where('id', '>', $this->getRecord()->id)
                    ->orderBy('id', 'asc')
                    ->first();

                $this->save();

                redirect(static::getResource()::getUrl('edit', ['record' => $nextRecord]));
            }),
    ];
}
Was this page helpful?