F
Filament•13mo ago
joao nivaldo

FileUpload display order change

Hello, when I use FileUpload with multiple images after it saves and I refresh the page it is showing the images in the reverse order of the ones that came in the array. Does anyone know how to resolve this? Thanks.
9 Replies
Patrick Boivin
Patrick Boivin•13mo ago
Hi @joaonivaldo, have you tried ->enableReordering() on the FileUpload field?
joao nivaldo
joao nivaldo•13mo ago
It's already enabled. The problem is in the initial load that it comes in reverse order and I really need to keep the order that the client chooses for the images.
Patrick Boivin
Patrick Boivin•13mo ago
Maybe ->appendFiles()
joao nivaldo
joao nivaldo•13mo ago
Thank you very much. It worked really well. I thought I was going to have to use another component for this. I just didn't find anything in the documentation either in Filament or in FilePond about this appendFiles method. Could you point me where I can see more about this method? It was worth it.
awcodes
awcodes•13mo ago
Are you using a relationship for them?
Patrick Boivin
Patrick Boivin•13mo ago
I just found it by looking around in the source code. Not a super good answer, I know, but at least there's that 🙂
awcodes
awcodes•13mo ago
I think it’s down to the fact that the array is assigned uuids as the keys for the array. Meaning that preserving the order could be difficult to do from that. Or I could be thinking of a different component. Just thinking about it from the curator standpoint where I had to compensate for relationships since they’re not orderable by default.
Patrick Boivin
Patrick Boivin•13mo ago
Sounds like a repeater/builder indeed, but I haven't looked at the data structure for the multiple file upload, you might be right
awcodes
awcodes•13mo ago
Relationships have to have an orderable column on a pivot table to make them work. And the relationship has to be defined to compensate it.
Want results from more Discord servers?
Add your server
More Posts