When rendering a CheckboxList field with dynamic options where an enum is returned by the options closure, the descriptions are not displayed. This issue occurs even though the enum implements both HasDescription and HasLabel.
Code example:
enum Options: string implements HasDescription, HasLabel
{
case FOO = 'foo';
case BAR = 'bar';
public function getDescription(): ?string
{
return match ($this) {
self::FOO => 'Foo Description',
self::BAR => 'Bar Description',
};
}
public function getLabel(): ?string
{
return match ($this) {
self::FOO => 'Foo Label',
self::BAR => 'Bar Label',
};
}
}
///
class TestComponent extends Livewire
{
public function form(Form $form): Form
{
return $form
->schema([
CheckboxList::make('test')->options(fn () => Options::class),
]);
}
Expected behavior
The descriptions (Foo Description and Bar Description) should be displayed below their respective labels (Foo Label and Bar Label) in the rendered form.
Steps to reproduce
Render a form with a CheckboxList field
Write a closure returning the options
Return an enum class which implements HasLabel and HasDescription
Reproduction repository (issue will be closed if this is not valid)
Package
filament/filament
Package Version
v3.2.108
Laravel Version
v11.21.0
Livewire Version
v3.5.6
PHP Version
8.3.12
Problem description
When rendering a CheckboxList field with dynamic options where an enum is returned by the options closure, the descriptions are not displayed. This issue occurs even though the enum implements both HasDescription and HasLabel.
Code example:
Expected behavior
The descriptions (Foo Description and Bar Description) should be displayed below their respective labels (Foo Label and Bar Label) in the rendered form.
Steps to reproduce
Reproduction repository (issue will be closed if this is not valid)
https://github.com/standaniels/filament/tree/fix-descriptions-for-dynamic-options
Relevant log output
No response
Donate 💰 to fund this issue