© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
Husky110

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;
                                })
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
$tag
$tag
comes in as an empty model. If I use
$data
$data
instead of
$tag
$tag
, I get an empty array. I already tried to use
->formFill(['tag_id' => $tag->id])
->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)
use ($tag)
. Filament doesn’t know about your tag so it can’t inject it as an argument
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

passing data to infolist action
FilamentFFilament / ❓┊help
3y ago
Action form how send data ?
FilamentFFilament / ❓┊help
2y ago
Database Notification Actions: Infolist in action?
FilamentFFilament / ❓┊help
3y ago
How to test Infolist Action?
FilamentFFilament / ❓┊help
2y ago