FilamentF
Filament3y ago
4 replies
ElCoco

Why this RepeatableEntry code doesn't work as expected

public function conversationsList(Infolist $infolist): Infolist
    {
        $user = User::find(auth()->id());
        $conversations = $user->conversations()->select('id', 'name')->get()->toArray();
        // dd($conversations);
        return $infolist
            ->schema([
                FilamentInfolists\RepeatableEntry::make('conversations')
                ->hiddenLabel(true)
                ->schema([
                    FilamentInfolists\TextEntry::make('id')
                    ->hiddenLabel()
                    ->action(Action::make('select')
                        ->action(function (int $id) {
                            dd($id);
                        })
                    ),
                    FilamentInfolists\TextEntry::make('name')
                    ->hiddenLabel()
                ])
            ])
            ->state([
                'conversations' => $conversations
            ])
            ->columns(1);
    }


The list shows up properly, but when I click in the action I get:
An attempt was made to evaluate a closure for [Filament\Infolists\Components\Actions\Action], but [$id] was unresolvable.

I am trying to get the value of 'id' in the current component action.

I also tried other stuff like $state or injecting Get and some desperate random stuff...Nothing seems to work.

The only thing that gives sings if working is:
->action(function (array $data) {
    dd($data);
})

But this gives me an empty array.
Was this page helpful?