F
Filament15mo ago
Ehsan

Spatie Media Library plugin not working in livewire form component

I am trying to create a livewire form component using Filament v3 by following https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component I am trying to add a Spatie Media Library field to the form SpatieMediaLibraryFileUpload::make('photo') and shows normal file upload field which fails validation on submit (Probably because of changes to file field by Spatie plugin). On the admin panel, it is working fine and shows filepod snippet. I am using app layout of Filament v3 with all Filament styles & scripts injected.
Solution:
Removing the manual entry for Alpine.start() in resources/js/app.js fixed the issue.
Jump to solution
15 Replies
krekas
krekas15mo ago
Console errors?
Ehsan
EhsanOP15mo ago
There are no console errors.
Ehsan
EhsanOP15mo ago
This is how the component is rendered on page without any errors, but no requests are triggered to backend when the file is uploaded. Also the basic required validation fails on this file upload.
Ehsan
EhsanOP15mo ago
Same is happening with basic FileUpload component
Ehsan
EhsanOP15mo ago
This is how it looks on backend
krekas
krekas15mo ago
I guess you are missing some styles or scripts. I think there's @filamentScripts and @FilamentStyles
Ehsan
EhsanOP15mo ago
This is the layout view. Everything is included.
Ehsan
EhsanOP15mo ago
Now I am getting an error Alpine Expression Error: $wire is not defined on file component
krekas
krekas15mo ago
the way you use alpine i guess is wrong because i can see filepond correctly in a livewire component which isn't in the panel
krekas
krekas15mo ago
Ehsan
EhsanOP15mo ago
@krekas This one is on admin panel side, not the livewire form component
krekas
krekas15mo ago
In my screenshot it is not
Ehsan
EhsanOP15mo ago
Can you please share the component view file and the layout on how you have implemented it.
krekas
krekas15mo ago
just go through the docs how to install everything in the existhing app
Solution
Ehsan
Ehsan15mo ago
Removing the manual entry for Alpine.start() in resources/js/app.js fixed the issue.
Want results from more Discord servers?
Add your server