Add a custom property to a SpatieMediaLibraryFileUpload based on another text field in Repeater

Repeater::make('gallery') ->schema([ SpatieMediaLibraryFileUpload::make('image') ->collection('gallery') ->customProperties(['caption' => '...']) ->image() ->required(), TextInput::make('caption') ->required(), ]) ->addActionLabel('Add image'), how to set the caption property based on the text input field?
7 Replies
LeandroFerreira
maybe?
TextInput::make('caption')->live(onBlur:true)
TextInput::make('caption')->live(onBlur:true)
->customProperties(fn(Get $get):array => ['caption' => $get('caption')])
->customProperties(fn(Get $get):array => ['caption' => $get('caption')])
Mhmoud Khalaf
Mhmoud Khalaf4w ago
It doesn't work: "Column not found: 1054 Unknown column 'gallery' in 'field list'"
LeandroFerreira
ohh sorry. SpatieMediaLibrary is associated with your model, so I think you can't add this in the repeater Did you follow the instructions?
Mhmoud Khalaf
Mhmoud Khalaf4w ago
Yes, I do, and it works with something like, SpatieMediaLibraryFileUpload::make('gallery') ->multiple() ->collection('gallery') but now I want to add a caption for images. Is there another way to add a caption without a Repeater?
LeandroFerreira
customProperties I think, but not by file, if you are using multiple I think curator has this option: https://filamentphp.com/plugins/awcodes-curator Maybe you could check this or other plugins to achieve what you need
Filament
Curator by Adam Weston - Filament
A media manager / picker plugin for Filament Panels.
Mhmoud Khalaf
Mhmoud Khalaf4w ago
The problem is that the curator package doesn't support the Spatie Media Library.