© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
7 replies
jjo63

ToggleColumn - making conditionally invisible

Hi I have the following code snippet

                ToggleColumn::make('is_indexed')
                    ->label('Index?')
                    ->onColor('info')
                    ->beforeStateUpdated(function ($record, $state) {
                        
                        // Runs before the state is saved to the database.
                    })
                    ->afterStateUpdated(function ($record, $state) {
                        // Runs after the state is saved to the database.
                    })
                    ->visible(function ($record) {
                      dd($record->record_type);

                    })
                ToggleColumn::make('is_indexed')
                    ->label('Index?')
                    ->onColor('info')
                    ->beforeStateUpdated(function ($record, $state) {
                        
                        // Runs before the state is saved to the database.
                    })
                    ->afterStateUpdated(function ($record, $state) {
                        // Runs after the state is saved to the database.
                    })
                    ->visible(function ($record) {
                      dd($record->record_type);

                    })


In the
beforeStateUpdated
beforeStateUpdated
I can access $record - but within
visible
visible
I am unable to (i.e. generates an error - "Attempt to read property "record_type" on null").

I don't understand why $record isn't universally available to me - but accepting that's the case, how would I access the current record within the
visible
visible
method so that I can determine whether the toggle should be shown or not?

thanks for your help!
j
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

conditionally hiding ToggleColumn
FilamentFFilament / ❓┊help
2y ago
ToggleColumn
FilamentFFilament / ❓┊help
10mo ago
ToggleColumn Pivot
FilamentFFilament / ❓┊help
3y ago
ToggleColumn Action
FilamentFFilament / ❓┊help
3y ago