F
Filament2mo ago
lupoz

Count chars field not working

I want to create a column that shows the length of the field title:
TextColumn::make('Title')
->formatStateUsing(function ($record) {
$length = strlen($record->title);
return "<b>{$length}</b> /" . LENGTH_TITLE;
})
->html(),
TextColumn::make('Title')
->formatStateUsing(function ($record) {
$length = strlen($record->title);
return "<b>{$length}</b> /" . LENGTH_TITLE;
})
->html(),
Solution:
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
...
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira2mo ago
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
TextColumn::make('title')
->formatStateUsing(fn (string $state): string => strlen($state))
lupoz
lupozOP2mo ago
Thanks!
Want results from more Discord servers?
Add your server