Problems with SpatieMediaLibraryFileUpload on a modal action.
Hi everybody,
I'm trying to add a media uploader on a CreateAction, the usecase here is to add some files to a note being added to a resource. I'm using the following code ( see screenshot). Problem is that the media gets saved on the parent model, instead of my Note::class model. Does anybody know how this can be fixed?
8 Replies
@ralphjsmit could you help me with this?
Hi! I don't maintain the SpatieMediaLibraryFileUpload plugin, but only the MediaLibrary plugin: https://filamentphp.com/plugins/ralphjsmit-media-library-manager.
Perhaps that plugin works better for your use case :)
you can pass in:
->model()
and pass in the note model.
@toeknee , that doesn't do anything as I don't know the record yet The action creates a note, with the media attached to the note but it attaches it to the parent model. When attaching ->model(Note::class) to the medialibrary field, nothing gets saved.
Ahh ok, so you are trying to save to the relationship note_attachements on notes
correct
We have that working here, one second]
me and @Diogo Pinto (mainly them) created a re-usable notes action. Ok I see how we are handling it here. We use FileUpload but after file upload we then call the AddMedia method from spatie
the form field
@toeknee thanks for the help, will try that!