Form Select with options(MyEnum::class) and multiple() has livewire error when removing a value.

Error I am getting : "__rm__" is not a valid backing value for enum Setup is a basic enum that implements Filament\Support\Contracts\HasLabel. Cast to convert it to json in the DB. on the Resource:
Forms\Components\Select::make('roles')
->multiple()
->options(UserRoles::class)
,
Forms\Components\Select::make('roles')
->multiple()
->options(UserRoles::class)
,
Any clues, or am I just trying to do something weird and is there a better implementation ?
10 Replies
MohamedSabil83
MohamedSabil8314mo ago
Can you paste/attach your enum here?
MichaelMdp
MichaelMdpOP14mo ago
This is the enum:
use Filament\Support\Contracts\HasLabel;

enum UserRoles: string implements HasLabel
{
case SuperAdmin = 'super_admin';
case Admin = 'admin';
case BackendUser = 'backend_user';

public function getLabel(): ?string
{
return match ($this) {
self::SuperAdmin => 'super admin',
self::Admin => 'admin',
self::BackendUser => 'backend user',
};
}
}
use Filament\Support\Contracts\HasLabel;

enum UserRoles: string implements HasLabel
{
case SuperAdmin = 'super_admin';
case Admin = 'admin';
case BackendUser = 'backend_user';

public function getLabel(): ?string
{
return match ($this) {
self::SuperAdmin => 'super admin',
self::Admin => 'admin',
self::BackendUser => 'backend user',
};
}
}
awcodes
awcodes14mo ago
iirc, "rm" is an internal LW tracker for removing items when dom diffing. seems really odd to me that the enum is trying to use it.
MichaelMdp
MichaelMdpOP14mo ago
the select is flagged as multiple(), so I can 'remove' stuff from the select.
awcodes
awcodes14mo ago
yea, i don't think you're doing anything wrong. I'm just surprised that LW is trying to assign it as a value in the options array can you run php artisan about and let us know which versions of Filament and Livewire are installed.
MichaelMdp
MichaelMdpOP14mo ago
Environment ........................................................
Application Name ........................................... Laravel
Laravel Version ............................................ 10.24.0
PHP Version ................................................. 8.1.16
Composer Version ............................................. 2.5.8
Environment .................................................. local
Debug Mode ................................................. ENABLED
URL ....................................... tracoa-upgrade.ddev.site
Maintenance Mode ............................................... OFF

Filament ...........................................................
Packages ........... filament, forms, notifications, support, tables
Version .................................................... v3.0.59
Views ................................................ NOT PUBLISHED

Livewire ...........................................................
Livewire .................................................... v3.0.5
Environment ........................................................
Application Name ........................................... Laravel
Laravel Version ............................................ 10.24.0
PHP Version ................................................. 8.1.16
Composer Version ............................................. 2.5.8
Environment .................................................. local
Debug Mode ................................................. ENABLED
URL ....................................... tracoa-upgrade.ddev.site
Maintenance Mode ............................................... OFF

Filament ...........................................................
Packages ........... filament, forms, notifications, support, tables
Version .................................................... v3.0.59
Views ................................................ NOT PUBLISHED

Livewire ...........................................................
Livewire .................................................... v3.0.5
I'm in the middle of upgrade an existing project, so should all be relative up-to-date this used to work in v2
awcodes
awcodes14mo ago
It should be working fine. I haven't had any issues with using enums in v3. that's why i'm trying to figure this out, because it doesn't make sense. filament is up to 3.0.62. maybe composer update will resolve the issue. not sure. Livewire version is fine.
MichaelMdp
MichaelMdpOP14mo ago
upgrading doesn't help I can setup a repro If you like, or report in github ?
awcodes
awcodes14mo ago
Report it with a reproduction repo, please. It's very strange.
MichaelMdp
MichaelMdpOP14mo ago
GitHub
Form Select with enum options and multiple generates an error when ...
Package filament/forms Package Version v3.0.62 Laravel Version 10.24.0 Livewire Version v3.0.5 PHP Version 8.1.16 Problem description I have a basic Enum with a cast to convert it to json in the DB...
Want results from more Discord servers?
Add your server