© 2026 Hedgehog Software, LLC

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

How to pass record to table row action?

Hi guys, I am trying dynamically create actions for my table rows:
public function table(Table $table): Table
{
    return parent::table($table)
        ->columns([...])
        ->actions([
            Tables\Actions\ActionGroup::make([
                [...$this->getContractStatusActions(fn (Contract $record) => $record)],
            ]),
        ]);
}

private function getContractStatusActions(\Closure $closure): array
{
    /** @var Contract $contract */
    $contract = $closure();

    $nextState = $contract->status->getNextState();

    return collect($nextState)
        ->map(function (ContractStatus $state) use ($contract) {
            return Tables\Actions\Action::make('updateStatus')
                ->label($state->getLabel())
                ->action(fn () => $contract->update(['status' => $state]));
        })
        ->toArray();
}
public function table(Table $table): Table
{
    return parent::table($table)
        ->columns([...])
        ->actions([
            Tables\Actions\ActionGroup::make([
                [...$this->getContractStatusActions(fn (Contract $record) => $record)],
            ]),
        ]);
}

private function getContractStatusActions(\Closure $closure): array
{
    /** @var Contract $contract */
    $contract = $closure();

    $nextState = $contract->status->getNextState();

    return collect($nextState)
        ->map(function (ContractStatus $state) use ($contract) {
            return Tables\Actions\Action::make('updateStatus')
                ->label($state->getLabel())
                ->action(fn () => $contract->update(['status' => $state]));
        })
        ->toArray();
}

I am still getting this error:
Too few arguments to function App\Filament\Resources\ContractResource\Pages\ListContracts::App\Filament\Resources\ContractResource\Pages\{closure}(), 0 passed in /Users/me/Developer/Sites/leasing/app/Filament/Resources/ContractResource/Pages/ListContracts.php on line 91 and exactly 1 expected
Too few arguments to function App\Filament\Resources\ContractResource\Pages\ListContracts::App\Filament\Resources\ContractResource\Pages\{closure}(), 0 passed in /Users/me/Developer/Sites/leasing/app/Filament/Resources/ContractResource/Pages/ListContracts.php on line 91 and exactly 1 expected
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Pass record to infolist from action
FilamentFFilament / ❓┊help
2y ago
Custom table row action
FilamentFFilament / ❓┊help
3y ago
Table row record action combined with expandableLimitedList unexpected results
FilamentFFilament / ❓┊help
11mo ago
Dispatch Table Record Action
FilamentFFilament / ❓┊help
3mo ago