File upload with Livewire component
I am trying to use
SpatieMediaLibraryFileUpload
component with Livewire component in a filament form. I have followed steps as mentioned at https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#setting-up-the-livewire-component to make the form work, but the files somehow are not getting uploaded.
The above element code works in filament v3 admin panel with a filepond component.
I am trying to save the data in a custom method with following code
It saves the data to database without the spatie media upload.
DDing $this->form->getState();
doesn't show the member_photos
element in it.Solution:Jump to solution
The solution is to save the relationships manually with model creation. Means, if you are passing
Model::class
to the ->model(Model::class);
form creation method, you have to manually save the relationships by calling saveRelationships()
method on form
class.
$this->form->model($member)->saveRelationships();
...1 Reply
Solution
The solution is to save the relationships manually with model creation. Means, if you are passing
Model::class
to the ->model(Model::class);
form creation method, you have to manually save the relationships by calling saveRelationships()
method on form
class.
$this->form->model($member)->saveRelationships();