formatStateUsing() and a nullable boolean column
I have a nullable boolean column in a table like:
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.
will not dump anything at all, but works as expected for the non-null values.
same with
Any insight would be appreciated.Solution:Jump to solution
Try
getStateUsing()
. null
values are filteres and there is not formatStateUsing()
for them5 Replies
You can try with this https://www.php.net/manual/en/function.isset.php
Solution
Try
getStateUsing()
. null
values are filteres and there is not formatStateUsing()
for them@Dennis Koch Ah, that makes sense.
Do I simply use the
HasState
trait and call it the same way as formatStateUsing()
?
Interestingly fails with no errors (dropped connection) when I attempt to do that.
Ah, hold on
My bad, it was still trying to inject a string, which obviously would fail
Injecting the Model, works as expectedNot sure why you mention
HasState
trait now, since you didn't use that one before. But you can use getStateUsing()
prettry much the same like your first exampleThanks @Dennis Koch, you saved me a lot of time I would've spent debugging this.