© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
9 replies
Johan

formatStateUsing not called if value is null

                Tables\Columns\TextColumn::make('cancelled_at')
                    ->label('Cancelled')
                    ->formatStateUsing(fn (?string $state) => $state ? 'Yes' : 'No')
                    ->colors([
                        'success' => static fn (?string $state): bool => empty($state),
                        'danger' => static fn (?string $state): bool => !empty($state),
                    ]),
                Tables\Columns\TextColumn::make('cancelled_at')
                    ->label('Cancelled')
                    ->formatStateUsing(fn (?string $state) => $state ? 'Yes' : 'No')
                    ->colors([
                        'success' => static fn (?string $state): bool => empty($state),
                        'danger' => static fn (?string $state): bool => !empty($state),
                    ]),


This does echo "Yes" but if
cancelled_at
cancelled_at
is
null
null
it wont show "No".
Solution
Use
getStateUsing()
getStateUsing()
instead
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

formatStateUsing not being called
FilamentFFilament / ❓┊help
16mo ago
IconEntry not showing icon if value is null
FilamentFFilament / ❓┊help
3y ago
TextColum V3 - formatStateUsing doesn't run if null
FilamentFFilament / ❓┊help
3y ago
DatePicker value if DB field is null
FilamentFFilament / ❓┊help
3y ago