β SpatieMediaLibraryFileUpload on repeater with relation doesn't work
Hi !
I'm trying to have a SpatieMediaLibraryFileUpload on every block generated by my repeater.
I'm having an error :
Filament\Forms\Components\SpatieMediaLibraryFileUpload::Filament\Forms\Components\{closure}(): Argument #2 ($record) must be of type Spatie\MediaLibrary\HasMedia, Spatie\MediaLibrary\MediaCollections\Models\Media given, called in /app/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
Filament\Forms\Components\SpatieMediaLibraryFileUpload::Filament\Forms\Components\{closure}(): Argument #2 ($record) must be of type Spatie\MediaLibrary\HasMedia, Spatie\MediaLibrary\MediaCollections\Models\Media given, called in /app/vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
1 Reply
Here my code
How Can I use SpatieMediaLibraryFileUpload with my repeater ?
Thanks
// Gallery form
public function form(Form $form): Form
{
return $form
->columns(3)
->schema([
Forms\Components\TextInput::make('title') // Gallery Title
->label('Title')
->required()
->columnSpanFull()
->maxLength(255),
Forms\Components\Textarea::make('description') // Gallery Title
->label('Description')
->columnSpanFull()
->rows(3),
Forms\Components\Repeater::make('media')
->label('Images')
->columnSpanFull()
->relationship('media') // Images from my gallery
->grid(3)
->label(false)
->schema([
Forms\Components\SpatieMediaLibraryFileUpload::make('media')
->label(false)
->disk('s3-public')
->moveFiles(),
Forms\Components\TextInput::make('title')
->label(false)
->placeholder('Title')
->reactive()
->maxLength(255),
Forms\Components\Textarea::make('description')
->label(false)
->placeholder('Description')
->rows(3),
]),
]);
}
// Gallery form
public function form(Form $form): Form
{
return $form
->columns(3)
->schema([
Forms\Components\TextInput::make('title') // Gallery Title
->label('Title')
->required()
->columnSpanFull()
->maxLength(255),
Forms\Components\Textarea::make('description') // Gallery Title
->label('Description')
->columnSpanFull()
->rows(3),
Forms\Components\Repeater::make('media')
->label('Images')
->columnSpanFull()
->relationship('media') // Images from my gallery
->grid(3)
->label(false)
->schema([
Forms\Components\SpatieMediaLibraryFileUpload::make('media')
->label(false)
->disk('s3-public')
->moveFiles(),
Forms\Components\TextInput::make('title')
->label(false)
->placeholder('Title')
->reactive()
->maxLength(255),
Forms\Components\Textarea::make('description')
->label(false)
->placeholder('Description')
->rows(3),
]),
]);
}