F
Filament14mo ago
jouni.i

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
Patrick Boivin14mo ago
What is "not set" in this context? NULL in the database?
jouni.i
jouni.iOP14mo 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
Patrick Boivin14mo ago
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
ZedoX14mo ago
->default('not set') ?
Patrick Boivin
Patrick Boivin14mo ago
Not sure if default() applies in the context of a List but something to try
cheesegrits
cheesegrits14mo ago
So in this case, it's a choice between default() and placeholder(). Personally I would go for placeholder().
ZedoX
ZedoX14mo ago
Ooo i didn't know about placeholder, time to refactor my code
Patrick Boivin
Patrick Boivin14mo ago
Same, this is pretty cool! Thanks @Hugh Messenger
jouni.i
jouni.iOP14mo ago
Thx all
Want results from more Discord servers?
Add your server