Exception with Filament 3: Property type not supported in Livewire
Hello everyone,
I hope you all are doing well. I'm currently facing an issue with Filament after an upgrade and I hope to get some help or pointers on how to solve it. I've been using the package Spatie Laravel Model States to cast attributes to a state class without any issues in Filament v2.
However, after upgrading, any attribute that is cast to a class causes the following exception:
This didn't occur with the previous version of Filament and has been causing some roadblocks in my development process. Does anyone have an idea on what could be causing this and how to fix it? Any guidance or suggestions would be much appreciated.
Thank you in advance.
GitHub
GitHub - spatie/laravel-model-states: State support for models
State support for models. Contribute to spatie/laravel-model-states development by creating an account on GitHub.
Solution:Jump to solution
Looking at the package docs, in their Payment example, I think having the PaymentState implement Wireable to set/get the underlying value with toLivewire and fromLivewire would work.
7 Replies
For more context, this only happens in the
EditRecord
and ViewRecord
classesSounds like you may need to make those classes "wireable", with to/fromLivewire methods for serializing / unserializing the underlying data. LW3 limits the types it natively supports as properties, and anything else you want to use needs to be "wireable".
https://livewire.laravel.com/docs/properties#supported-property-types
Laravel
Properties | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Ultimately, Spatie might be able to take care of it with a synthesizer, although I don't know enough about the Model States package to know if that would be possible. But until they address compatibility with LW3, handling it by making your classes wireable is probably the only solution.
Yea, this has to be an issue in the Spatie Package. It's weird that the property name is an array.
Solution
Looking at the package docs, in their Payment example, I think having the PaymentState implement Wireable to set/get the underlying value with toLivewire and fromLivewire would work.
Ideally this would be done in Spatie's State class, but rolling your own would work for now, till they update their code for LW3.
@Hugh Messenger, thank you. Implementing Wireable worked, good catch! Thanks again.