spatie / medialibrary.pro

The source code of medialibrary.pro
https://medialibrary.pro
36 stars 9 forks source link

Loading saved data in UI component #40

Closed sten closed 3 years ago

sten commented 3 years ago

Thanks for the great UI components! We just bought a license and love the overall features.

One thing is not clear: how can I load already uploaded files in the form component? For example, in an edit form we need to load the already uploaded files, so they can be removed or new ones added to it.

I achieved this functionality with the x-media-library-collection component and the :model and collection attribute. However with the x-media-library-attachment component I cannot get it to work. I try to load the same array structure in the :media attribute, but it appears it cannot be set. The constructor does this: $this->media = old($name) ?? [];

Should edits always be done with the x-media-library-collection? Thanks for your help!

Some improvement ideas for the docs:

freekmurze commented 3 years ago

Edits should indeed always be done with x-media-library-collection the attachment is meant for uploads only.

Thanks for those suggestions, we'll try to improve on that.

Feel free to PR improvements 👍