© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•12mo ago•
10 replies
Arnold Schwarzenegger

Enum is cast when creating but not editing

I have the following model (simplified)
class Config extends Model
{
    protected $casts = [
     'config_type' => ConfigType::class,
    ];
}
class Config extends Model
{
    protected $casts = [
     'config_type' => ConfigType::class,
    ];
}

and the following form resource
public static function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\Select::make('config_type')
                ->required()
                ->default(ConfigType::MAPPER)
                ->live()
                ->enum(ConfigType::class)
                ->options(ConfigType::class),
            Forms\Components\Fieldset::make()
                ->statePath('config')
                ->schema(fn (Forms\Get $get) =>
                    dd($get('config_type')) // The problem is here
        ]);
}
public static function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\Select::make('config_type')
                ->required()
                ->default(ConfigType::MAPPER)
                ->live()
                ->enum(ConfigType::class)
                ->options(ConfigType::class),
            Forms\Components\Fieldset::make()
                ->statePath('config')
                ->schema(fn (Forms\Get $get) =>
                    dd($get('config_type')) // The problem is here
        ]);
}


In the above example, when I create a new
Config
Config
, the
$get('config_type')
$get('config_type')
call returns and
ConfigType
ConfigType
enum as expected

However, when I edit the resource, the same call returns a
string
string
(with the value of the enum) instead of an enum object as expected.

Am I doing something wrong or is this just how filament works?
Solution
it seems the issue is on your ->default()
it should be ->default(ConfigType::MAPPER->value)

you can keep the options(), it is already correct. no enum() needed.

it should be working on create and edit
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Enum cast not working when editing a resource
FilamentFFilament / ❓┊help
3y ago
DatePicker creating records wrongly but editing correctly
FilamentFFilament / ❓┊help
3y ago
Saving related items when editing/creating a resource
FilamentFFilament / ❓┊help
3y ago
Creating records and editing information
FilamentFFilament / ❓┊help
3y ago