© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Simon

SpatieMediaLibraryFileUpload not working on $this->form->fill() after upgrading to v3

I upgraded to Filament v3 and everything has been super smooth except for one part

For some reason the SpatieMediaLibrary plugin (which is also upgraded to v3) is not operating as expected. I'm getting the following error when my form component loads:

Filament\Forms\Components\SpatieMediaLibraryFileUpload::Filament\Forms\Components\{closure}(): Argument #2 ($file) must be of type string, array given, called in /vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35
Filament\Forms\Components\SpatieMediaLibraryFileUpload::Filament\Forms\Components\{closure}(): Argument #2 ($file) must be of type string, array given, called in /vendor/filament/support/src/Concerns/EvaluatesClosures.php on line 35


This seems to stem from using the media library to populate the form in the
mount()
mount()
method of the component, which looks like this:

public function mount()
{
    $this->developer = auth()->user()->developer;

    $this->form->fill([
        'photo' => $this->developer->getMedia('photo')
    ]);
}
public function mount()
{
    $this->developer = auth()->user()->developer;

    $this->form->fill([
        'photo' => $this->developer->getMedia('photo')
    ]);
}


If I remove this line or change it to a simple value (e.g. a string), the form loads and the component renders, but obviously it doesn't load with any pre-filled data (i.e. any images that were previously uploaded)

Does anyone know what needs to change here?
Solution
I found the cause... I was missing the call to
->model()
->model()
on the end of my
$form
$form
in the component

// Before...
public function form(Form $form): Form
{
  return $form->schema([...])->statePath('data');
}

// After...
public function form(Form $form): Form
{
  return $form->schema([...])->statePath('data')->model($modelInstance);
}
// Before...
public function form(Form $form): Form
{
  return $form->schema([...])->statePath('data');
}

// After...
public function form(Form $form): Form
{
  return $form->schema([...])->statePath('data')->model($modelInstance);
}
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Fill form after mount in v3?
FilamentFFilament / ❓┊help
3y ago
Livewire not working properly after upgrading to Filament v3
FilamentFFilament / ❓┊help
3y ago
Problem After Upgrading to V3
FilamentFFilament / ❓┊help
3y ago
view not defined after upgrading to v3
FilamentFFilament / ❓┊help
3y ago