F
Filament5mo ago
Azorky

Fileupload order not correct

I noticed that when uploading new files, they are appended and not added to the state array in the correct order. I'm currently on the edit page and the 2 media items you see are already saved in the database. When I add a new file in the middle and dump the state in ->afterStateUpdated() the order is already incorrect. The new item is not in the middle, but at the end of the array.
Forms\Components\FileUpload::make('media')
->label(__('resources/todos.media'))
->multiple()
->reorderable()
->appendFiles()
->directory('proposal-option')
->disk('s3_public')
->downloadable()
->openable()
->afterStateUpdated(fn ($state) => dd($state))
->dehydrateStateUsing(fn ($state) => dd($state))
->beforeStateDehydrated(fn ($state) => dd($state))
->reorderUploadedFilesUsing(fn ($state) => dd($state)),
Forms\Components\FileUpload::make('media')
->label(__('resources/todos.media'))
->multiple()
->reorderable()
->appendFiles()
->directory('proposal-option')
->disk('s3_public')
->downloadable()
->openable()
->afterStateUpdated(fn ($state) => dd($state))
->dehydrateStateUsing(fn ($state) => dd($state))
->beforeStateDehydrated(fn ($state) => dd($state))
->reorderUploadedFilesUsing(fn ($state) => dd($state)),
I tried other functions as well, but in each of them the order is incorrect.
No description
No description
1 Reply
Azorky
AzorkyOP5mo ago
No description

Did you find this page helpful?