CodeMax
using ENUM class on Forms->Select Field return error
I get the follwing error trying to use an ENUM on a SelectField:
Filament\Forms\Components\Select::getOptions(): Return value must be of type array, string returned
my enum:
My cast:
My SelectField in Forms:
What am i missing?
php 8.2
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum Durations: string implements HasLabel
{
case OneDay = 'one_day';
case TwoDays = 'two_days';
case ThreeDays = 'three_days';
case FourDays = 'four_days';
public function getLabel(): ?string
{
return match ($this) {
self::OneDay => 'Ein Tag',
self::TwoDays => 'Zwei Tage',
self::ThreeDays => 'Drei Tage',
self::FourDays => 'Vier Tage',
};
}
}
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum Durations: string implements HasLabel
{
case OneDay = 'one_day';
case TwoDays = 'two_days';
case ThreeDays = 'three_days';
case FourDays = 'four_days';
public function getLabel(): ?string
{
return match ($this) {
self::OneDay => 'Ein Tag',
self::TwoDays => 'Zwei Tage',
self::ThreeDays => 'Drei Tage',
self::FourDays => 'Vier Tage',
};
}
}
'duration' => Durations::class,
'duration' => Durations::class,
Forms\Components\Select::make('duration')
->label('Dauer')
->options(Durations::class)
->required()
->reactive(),
Forms\Components\Select::make('duration')
->label('Dauer')
->options(Durations::class)
->required()
->reactive(),
6 replies
Show Repeaters first entry in Table View
I would like to show an entry in the Table View of Component. How can i access this data? This is my repeater:
Forms\Components\Repeater::make('dates')
->label("Termine")
->schema([
Forms\Components\Select::make('location')
->label('Ort')
->required()
->relationship('location', 'title'),
Forms\Components\DatePicker::make('date')
->timezone('Europe/Berlin')
->label("Datum")
->required(),
Forms\Components\TimePicker::make('start_time')
->timezone('Europe/Berlin')
->seconds(false)
->label("Startzeit")
->required(),
Forms\Components\TimePicker::make('end_time')
->timezone('Europe/Berlin')
->seconds(false)
->label("Endzeit")
->required(),
])
->columns(2)
->defaultItems(1)
->cloneable()
Forms\Components\Repeater::make('dates')
->label("Termine")
->schema([
Forms\Components\Select::make('location')
->label('Ort')
->required()
->relationship('location', 'title'),
Forms\Components\DatePicker::make('date')
->timezone('Europe/Berlin')
->label("Datum")
->required(),
Forms\Components\TimePicker::make('start_time')
->timezone('Europe/Berlin')
->seconds(false)
->label("Startzeit")
->required(),
Forms\Components\TimePicker::make('end_time')
->timezone('Europe/Berlin')
->seconds(false)
->label("Endzeit")
->required(),
])
->columns(2)
->defaultItems(1)
->cloneable()
39 replies