I got this enum class of periods or terms:
Term.php
<?php
namespace App\Enums;
enum Term : string
{
case ONE_MONTH = '1 month';
case THREE_MONTHS = '3 months';
case SIX_MONTHS = '6 months';
case TWELVE_MONTHS = '12 months';
}
So I have tested the following with dump
dd(array_map(
fn (Term $term) => $term->value,
Term::cases()
));
it outputs:
^ array:4 [▼
0 => "1 month"
1 => "3 months"
2 => "6 months"
3 => "12 months"
]
Now I want to pass each value into a Select input (of filamentphp.com ) like so:
Forms\Components\Select::make('term')->options([
array_map(
fn (Term $term) => $term->value,
Term::cases()
)
//Term::ONE_MONTH->value=>TERM::ONE_MONTH->name
]),
But I get the following error:
Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string, array given,
Well, it looks like I need to get the following syntax (as shown in the documentation):
use Filament\Forms\Components\Select;
Select::make('status')
->options([
'draft' => 'Draft',
'review' => 'In review',
'published' => 'Published',
])
So what am I missing to get the enum class values displayed in an input form?