[ Issue ] Enum Casting on Eloquent ORM
Hello fellas,
Can anyone let me know when a Eloquent Model has an enum caster ( It doesnt matter if its spatie package backed or PHP Native ones ) i always get the following error when trying to open forms/pages
Property type not supported in Livewire for property: ["bar"]
Being "bar" the actual value of the enum.
The current workaround i have found was to implement a Wireable to the enum, but to me it feels dirty.
To me its seems like Livewire / Filament doesnt know how to "transpile" this types directly?
Version: 3.0.0-beta.911 Replies
Where do you use these enum? Check out HasLabel trait etc.
Morning @Dennis Koch 🍆 ! When using in a table it works fine, but when i try to open any kind of resource view ( Edit/View ) it throws it.
I have checked the HasLabel, and i totally understand it, but while i can control my own enums, i cant control 3rd party packages enums, this would requirement me to extend all the packages enums to implement a HasLabel Trait? :p
Thanks ❤️
Not sure if this is solved in Livewire. I think enums aren’t supported yet. You probably found this issue, too? https://github.com/livewire/livewire/discussions/4411
GitHub
Allow enums for component properties · livewire livewire · Discussi...
Hi, I think it would make sense to allow PHP8.1 Enums as the type for component properties. Example: enum Type: string { case TYPE_A = 'a'; case TYPE_B = 'b'; } class MyComponent ex...
What does the form component look that you use?
Its just a normal field, but ill try to replicate in a clean repo and open a issue if thats the case, and yeah i checked that issue, but seems like its merged, so it should work in theory! Thanks a lot for your time Dennis! Gonna fiddle around
A Select field? Can you share some code?
No, has a TextColumn, since its a "visual" only Enum
I thought it's broken on Edit/View? 🤔
Indeed, i just have the enum on the table, but it refuses to open the edit/view parts, thats the weird part :p, i have actually removed the whole form part together
Try getting the state yourself:
Interesting, ill try that, i was only using
formatStateUsing
✅