TextColumn formatState if state if empty

how can i set default value if valid_from is empty? I would like to set the value to "not set"?
10 Replies
Patrick Boivin
What is "not set" in this context? NULL in the database?
jouni.i
jouni.iOP2y ago
yes we convert old laravel project to use filaments.. and old database is lot off rows where valid_from is null, we need inform users somehow about this..
Patrick Boivin
Something like this?
->formatStateUsing(function ($state) {
if (is_null($state)) {
return 'Something';
}

return $state;
})
->formatStateUsing(function ($state) {
if (is_null($state)) {
return 'Something';
}

return $state;
})
ZedoX
ZedoX2y ago
->default('not set') ?
Patrick Boivin
Not sure if default() applies in the context of a List but something to try
cheesegrits
cheesegrits2y ago
So in this case, it's a choice between default() and placeholder(). Personally I would go for placeholder().
ZedoX
ZedoX2y ago
Ooo i didn't know about placeholder, time to refactor my code
Patrick Boivin
Same, this is pretty cool! Thanks @Hugh Messenger
jouni.i
jouni.iOP2y ago
Thx all

Did you find this page helpful?