FilamentF
Filament3y ago
*

formatStateUsing() and a nullable boolean column

I have a nullable boolean column in a table like:
$table->boolean('decision')->nullable();

In my Filament table, I'm trying to display 'Pending' for the null value and 'Accepted' or 'Rejected' correspondingly for true and false

I do not get any $state or Model $record for the null values at all.

TextColumn::make('decision')
  ->badge()
  ->formatStateUsing(function (Model $record) {
      dump($record);
  })
  ...

will not dump anything at all, but works as expected for the non-null values.
same with
TextColumn::make('decision')
  ->badge()
  ->formatStateUsing(function (string $state) {
    dump($state)
  })
  ...


Any insight would be appreciated.
Solution
Try getStateUsing().
null
values are filteres and there is not formatStateUsing() for them
Was this page helpful?