Enums for datalist attribute values

Hello Filament community, I am really liking the use of enums in Filament. I wanted to ask if I can use them in datalist attributes in the form builder too? And if so, what would be best practices at the moment? Thank you.
Solution:
What about
->datalist(fn() => collect(Status::cases())->mapWithKeys(fn ($case) => [$case->value => $case->label()]))
->datalist(fn() => collect(Status::cases())->mapWithKeys(fn ($case) => [$case->value => $case->label()]))
...
Jump to solution
2 Replies
Solution
toeknee
toeknee4mo ago
What about
->datalist(fn() => collect(Status::cases())->mapWithKeys(fn ($case) => [$case->value => $case->label()]))
->datalist(fn() => collect(Status::cases())->mapWithKeys(fn ($case) => [$case->value => $case->label()]))
with Status class being the enum?
Mike Wink
Mike WinkOP4mo ago
Hello @toeknee thank you very much for that solution. I had developed something like this too. I just wondered if there is a more Filament / elegant / compact way.

Did you find this page helpful?