Repeater shows only the first item on edit form

Hi, newbie here. I am using repeater to allow user to upload images when create article.
The repeater repeatedly displays only the first image that was originally uploaded on edit form

I have checked the data in the mutateFormDataBeforeFill function. The array of images ($data['images']) appears to contain all the uploaded images, but for some reason, only the first image is being displayed repeatedly.

Repeater::make('images')                            
  ->schema([                      Forms\Components\SpatieMediaLibraryFileUpload::make('image')
  ->label('Image')
  ->collection(Article::MEDIA_COLLECTION_NAME)
  ->columnSpan('full')
  ->customProperties(['is_cover' => false])
  // disk is s3_public 
  ->disk(function () {
      if (config('filesystems.default') === 's3') {               return 's3_public';
          }
    })
  ->acceptedFileTypes(['image/*'])
  ->maxFiles(1)
  ->rules('image'),
  ])
  ->maxItems(20)
  ->collapsible()
  ->columnSpan('full')
  ->orderable('order_column')
  ->hidden(fn (Closure $get) => $get('type') !==     'multimedia'),


the mutateFormDataBeforeFill function:

    protected function mutateFormDataBeforeFill(array $data): array
    {
        $data['images'] = $this->record->getMedia(Article::MEDIA_COLLECTION_NAME)->toArray();
        dd($data['images']);
        return $data;
    }

Appreciate any insights on how I might resolve this issue.
Was this page helpful?