© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
17 replies
jelmerkeij

Set column action on condition

I have a table of products. Now if the product is of type 'bundled product' I want to bind an action that when clicked on the product name (the
TextColumn
TextColumn
) a modal opens displaying the contents of the product bundle.
But if the product is not of type 'bundled' then you shouldn't be able to click the product name since there are no bundled products to display in the modal. So the action should not be attached in that case.

Tables\Columns\TextColumn::make( 'name' )
  ->sortable()
  ->searchable()
  ->action(
    Tables\Actions\Action::make( 'showBundledProductsInModal' )
    ->action( fn() => null )
    ->modalHeading( 'Products in this bundle' )
    ->modalActions( [] )
    ->modalContent( fn( $record ) => view( 'filament.resources.products.table.bundled-products', [ 'record' => $record ] ) )
    // I've tried visible, hidden...
  //->visible( fn(): bool => ! empty( $this->record->product_type ) && (int) $this->record->product_type === ProductTypeEnum::BUNDLED->value )
),
Tables\Columns\TextColumn::make( 'name' )
  ->sortable()
  ->searchable()
  ->action(
    Tables\Actions\Action::make( 'showBundledProductsInModal' )
    ->action( fn() => null )
    ->modalHeading( 'Products in this bundle' )
    ->modalActions( [] )
    ->modalContent( fn( $record ) => view( 'filament.resources.products.table.bundled-products', [ 'record' => $record ] ) )
    // I've tried visible, hidden...
  //->visible( fn(): bool => ! empty( $this->record->product_type ) && (int) $this->record->product_type === ProductTypeEnum::BUNDLED->value )
),


I've tried
visible
visible
,
hidden()
hidden()
on the action but they don't seem to work. Not when using a closure and not when passing in a hardcoded
true
true
of
false
false
value. The product name is always clickable and the action is executed. 

Is it even possible to have the action conditionally set? How would I do that?

Thanks for any help and pointers.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Set Column with header action
FilamentFFilament / ❓┊help
16mo ago
Custom Action on custom column.
FilamentFFilament / ❓┊help
9mo ago
Table Action Url() on Column
FilamentFFilament / ❓┊help
3y ago
Table recordActions / Action condition
FilamentFFilament / ❓┊help
8mo ago