F
Filament2mo ago
Jon

How do I make text based boolean columns

If i have a boolean column that I would want to display as text instead of an icon, ->boolean doesnt exist on TEXTCOLUMN This example the column references 'is_book' where a false value would mean it is a magazine instead of a book. So I'd like the column labeled "type" to display either 'book', or 'magazine' depending on true or false.
2 Replies
KA
KA2mo ago
You can try TextColumn with ->formatStateUsing(). It should work.
TextColumn::make('is_book')
->formatStateUsing(fn (string $state): string => $state?'book':'magazine');
TextColumn::make('is_book')
->formatStateUsing(fn (string $state): string => $state?'book':'magazine');
Jon
JonOP2mo ago
thanks

Did you find this page helpful?