© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
6 replies
Hugo

Closure on column action doesn't work

Hi, there,

I'm trying to put an action on a column through a closure. I don't want the action to open if there is no
$record->url
$record->url
, however, as soon as I pass a closure the action doesn't fire at all and the modal never opens.

I've noticed that as soon as I pass a closure in the action, the click event is no longer “mountTableAction” but “callTableColumnAction”.

If anyone has any ideas 😄

Tables\Columns\IconColumn::make('url')
                    ->icon('heroicon-o-document')
                    ->placeholder('No media')
                    ->action(function ($record) {
                        if ($record->url) {
                            return Tables\Actions\Action::make()
                                ->modal()
                                ->modalContent(new HtmlString('<iframe src="' . $record->url . '" class="w-full h-full"></iframe>'))
                                ->modalHeading($record->url);
                        } else {
                            return null;
                        }
                    })
Tables\Columns\IconColumn::make('url')
                    ->icon('heroicon-o-document')
                    ->placeholder('No media')
                    ->action(function ($record) {
                        if ($record->url) {
                            return Tables\Actions\Action::make()
                                ->modal()
                                ->modalContent(new HtmlString('<iframe src="' . $record->url . '" class="w-full h-full"></iframe>'))
                                ->modalHeading($record->url);
                        } else {
                            return null;
                        }
                    })
Solution
I think the problem here is that the action isn't getting registered. Try this:
->action(
    Tables\Actions\Action::make('show_page_in_modal')
        ->disabled(fn ($record): bool => ! $record->url)
        ->modalContent(fn ($record) => new HtmlString('<iframe src="' . $record->url . '" class="w-full h-full"></iframe>'))
        ->modalHeading(fn ($record) => $record->url)
        ->action(fn () => null)
),
->action(
    Tables\Actions\Action::make('show_page_in_modal')
        ->disabled(fn ($record): bool => ! $record->url)
        ->modalContent(fn ($record) => new HtmlString('<iframe src="' . $record->url . '" class="w-full h-full"></iframe>'))
        ->modalHeading(fn ($record) => $record->url)
        ->action(fn () => null)
),
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

Associate Action doesn't work
FilamentFFilament / ❓┊help
2y ago
Export action doesn't work anymore
FilamentFFilament / ❓┊help
2y ago
"Create & Create another" doesn't work on custom action
FilamentFFilament / ❓┊help
15mo ago
$get doesn't work in action modal
FilamentFFilament / ❓┊help
3y ago