© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
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:

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',
    };
  }
}


My cast:

'duration' => Durations::class,
'duration' => Durations::class,


My SelectField in Forms:

Forms\Components\Select::make('duration')
                                    ->label('Dauer')
                                    ->options(Durations::class)
                                    ->required()
                                    ->reactive(),
Forms\Components\Select::make('duration')
                                    ->label('Dauer')
                                    ->options(Durations::class)
                                    ->required()
                                    ->reactive(),


What am i missing?
php 8.2
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Using an Enum class with Select in form
FilamentFFilament / ❓┊help
2mo ago
enum value in Forms\Components\Select
FilamentFFilament / ❓┊help
2y ago
\Forms\Components\Select
FilamentFFilament / ❓┊help
5mo ago
Filament Fabricator, return object from select field
FilamentFFilament / ❓┊help
3y ago