F
Filament3mo ago
daregu

Issue with Dynamic Class Application in `TextInput::make`

Hello, I’m encountering an issue with dynamically applying a class in the TextInput::make component of my project. Here’s the code I’m using:
TextInput::make('result')
->numeric()
->required()
->live()
->extraInputAttributes(function (Examen $record, Get $get, $state) {
$positivo = false;
$class = $positivo ? 'bg-green-100' : 'bg-red-100';
dump($class); // For debugging
return ['class' => (string) $class];
}, true)
TextInput::make('result')
->numeric()
->required()
->live()
->extraInputAttributes(function (Examen $record, Get $get, $state) {
$positivo = false;
$class = $positivo ? 'bg-green-100' : 'bg-red-100';
dump($class); // For debugging
return ['class' => (string) $class];
}, true)
The problem is that the class is not applied correctly when it is evaluated dynamically based on the $positivo variable. However, when I use a static class like this:
return ['class' => 'bg-red-600'];
return ['class' => 'bg-red-600'];
It works perfectly. But when I try to dynamically assign the class, it seems that the appropriate class is not applied. Does anyone have any ideas why this happens or how to resolve it? Thanks in advance for your help!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server