Error with Builder Field
Hello,
I did a fresh install of Laravel 10 with Filament 3, I created a resource page :
- Title - string
- Slug - string
- Content - JSON
I want to use the Builder component but I have 2 errors:
The first is :
Cannot use Filament\Forms\Components\Builder as Builder because the name is already in use
So I changed the name to :
use Filament\Forms\Components\Builder as PageBuilder
this solves the first error, but when I try to add a block and save the resource, I get a second error:
Array to string conversion
It does save the title and slug, but for the content it replaces them with ?
Have you come across this problem before?
Thanks !4 Replies
What filament form field are you using for content?
You can intercept the data before its saved by going into your CreatePages.php and adding this method
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data)
}
This will help you see the format of content before its saved and allow you to modify it to suit your underlying db schema
The Filament Builder component must return a JSON object, and my database schema is also a JSON.
the dd($data); returns an array, nothing abnormal, so I don't understand why Laravel is returning an error
Solution
Check the model is casting the attribute to an array.
Oh! I thought it was automatic, thanks for the answer!