FilamentF
Filament16mo ago
Matthew

Infolist and Actions confusion

Appreciate if someone can help me fill a gap in my knowledge with creating actions on infolists.

I'm getting my view page infolist from the function within the resource class:

public static function infolist(Infolist $infoList) : Infolist
    {
        return $infoList->schema(DetailsInfolist::getInfolistSchema());
    }


I have got suffix\prefix\hint actions working, but if I try and deploy just an action within the infolist, something like:

 Section::make('')
                ->id('idchecker')
                ->columns(3)
                ->schema([

                    IconEntry::make('uc_ident_checker')
                        ->columnSpanFull()
                        ->boolean()
                        ->label('Authorised to Validate ID')
                        ->inlineLabel(),

                    Action::make('resetStars')
                        ->icon('heroicon-m-x-mark')
                        ->color('danger')
                        ->requiresConfirmation()
                        ->action(function ($record) {
                            dd($record);
                        }),


It fails:

Filament\Infolists\ComponentContainer::Filament\Infolists\Concerns{closure}(): Argument #1 ($component) must be of type Filament\Infolists\Components\Component, Filament\Infolists\Components\Actions\Action given

I think I'm following the manual: https://filamentphp.com/docs/3.x/infolists/actions

Where am I confused ?
Solution
Look further down the page of the link you shared. You’re looking for anonymous actions. Basically, you can’t include an action directly, you have to wrap it with an ‘Actions’ entry.
Was this page helpful?