filament
filament copied to clipboard
Refreshing form with Action on FileUpload throws foreach() argument must be of type array|object, string given
Package
filament/filament
Package Version
v3.2.92
Laravel Version
v11.13.0
Livewire Version
v3.5.1
PHP Version
8.3.7
Problem description
I have an action button on a form. When I click it, it fetches the latest data from the database and should update in the form with $livewire->refreshFormData.
Every other field works but the FileUpload throw the error:
foreach() argument must be of type array|object, string given.
My action:
Section::make('Section')
->headerActions([
Action::make('refresh')
->icon('heroicon-o-arrow-path')
->color('warning')
->size(ActionSize::Small)
->hidden(fn ($record) => !$record)
->requiresConfirmation()
->action(function($record, $livewire) {
$record = $record->fresh();
$livewire->refreshFormData(['name', 'image']);
Notification::make()
->title('Refreshed data')
->success()
->send();
}),
])
I also tried setting $record->image = [$record->image] before refreshFormData.
Expected behavior
Also refreshing the FileUpload field.
Steps to reproduce
- Clone the reproduction repository and make a filament user
- Create a customer
- Edit the customer
- Click the
refreshaction button on the edit page
Reproduction repository (issue will be closed if this is not valid)
https://github.com/MarcelWeidum/filament-refresh-fileupload-bug
Relevant log output
foreach() argument must be of type array|object, string given
Donate 💰 to fund this issue
- You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
- 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
- Thank you in advance for helping us make maintenance sustainable!
->action(function($record, $livewire) {
$record = $record->fresh();
$record->image = [(string) Str::uuid() => $record->image];
$livewire->record = $record;
$livewire->refreshFormData(['name', 'image']);
Notification::make()
->title('Refreshed data')
->success()
->send();
}),