F
Filament13mo ago
KeyMe

Datalist options using enum in PHP 8.1+

Anyone knows how to use enum as options for a datalist text input? Currently, datalist() method doesn't accept string like if we were to pass enum::class to option() method.
Solution:
Figured out myself, in case anyone else wonders. app\Enums\enumclass ```js public static function toArray(): array {...
Jump to solution
1 Reply
Solution
KeyMe
KeyMe13mo ago
Figured out myself, in case anyone else wonders. app\Enums\enumclass
public static function toArray(): array
{
foreach (self::cases() as $key => $val) {
$array[$val->name] = Str::headline($val->name);
}
return $array;
}
public static function toArray(): array
{
foreach (self::cases() as $key => $val) {
$array[$val->name] = Str::headline($val->name);
}
return $array;
}
Want results from more Discord servers?
Add your server