Infolist - send data to Action

Hi - I need some help on creating an Infolist-Action. As you can see on the screenshot, I have a Chekpoint that has multiple tags. When a user clicks on the red button, the tag is beeing removed from the checkpoint. Right now I have this code:
Section::make('Tags')
                                ->columns(3)
                                ->schema(function (){
                                    $schema = [];
                                    foreach ($this->record->tags->sortBy('tagname') as $tag){
                                        $schema[] = TextEntry::make('tag_'.$tag->id)
                                            ->label(false)
                                            ->state($tag->tagname)
                                            ->suffixAction(
                                                Action::make('remove_tag')
                                                    ->icon('heroicon-o-x-mark')
                                                    ->button()
                                                    ->color('danger')
                                                    ->label(false)
                                                    ->tooltip('Remove Tag')
                                                    ->action(function (Tag $tag, $record){
                                                        dd($record, $tag);
                                                    })
                                            );
                                    }
                                    return $schema;
                                })

But $tagcomes in as an empty model. If I use $data instead of $tag, I get an empty array. I already tried to use ->formFill(['tag_id' => $tag->id]), but to no avail.
How do I send the tag-ID to the action? The relationship between Checkpoint -> Tag is BelongsToMany.
Thanks.
Bildschirmfoto_vom_2023-11-24_03-41-18.png
Solution
Try passing it to the function via use ($tag). Filament doesn’t know about your tag so it can’t inject it as an argument
Was this page helpful?