F
Filament14h ago
jmrufo

Several recordClasses

Hi guys. I would like to apply several css styles according to the added rules but I can't find a way to be able to do more than one check with recordClasses. If I create this rule it works perfectly: ->recordClasses( fn (Programming $record) => $record->canceled == 1 ? 'my-line-bg-canceled' : null ) But I would also like to add this other one that checks another property: ->recordClasses( fn (Programming $record) => $record->incident == 1 ? 'my-line-bg-incident' : null ); Can someone tell me if this is possible in filament. Thanks to all
3 Replies
Dennis Koch
Dennis Koch14h ago
Just combine both into one function
jmrufo
jmrufo13h ago
Can you tell me what it would be like?
Dennis Koch
Dennis Koch12h ago
It's just a method that returns a string of classes and you conditionally add to it
function () {
$classes = [];

if ($record->canceled == 1) {
$classes[] = 'my-line-bg-canceled';
}

// ...

return implode(' ', $classes);
}
function () {
$classes = [];

if ($record->canceled == 1) {
$classes[] = 'my-line-bg-canceled';
}

// ...

return implode(' ', $classes);
}
Want results from more Discord servers?
Add your server