© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
WishDasher

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()
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]));
            }),
    ];
}
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]));
            }),
    ];
}
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Replicate action: load form instead of save
FilamentFFilament / ❓┊help
2y ago
Form Action to save record, collapse parent repeater item and open next repeater item
FilamentFFilament / ❓┊help
3y ago
Form Action to save record, collapse parent repeater item and open next repeater item
FilamentFFilament / ❓┊help
3y ago
Can't save form action
FilamentFFilament / ❓┊help
2y ago