Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Changing UploadField "Select from files" default display order of all files from alphabetical to 'Created DESC' ?


Go to End


2 Posts   974 Views

Avatar
neilcreagh

Community Member, 136 Posts

26 May 2017 at 3:03am

Since 3.2 the UploadField "Select from files" shows files in all folders by default. It looks like these are in alphabetical order at the moment — is there an easy way to change the default to display these by newest files first?

At the moment this requires clicking on the 'Created' header twice each time before then selecting the file - and on a site with a lot of files this can be very slow. If you're choosing adding a lot of files that you've just uploaded to data objects this could be very helpful.

Avatar
neilcreagh

Community Member, 136 Posts

26 May 2017 at 3:24am

Update: So for the moment I've done this by directly editing the UploadField.php file in framework/forms (I know, I shouldn't)
On line 1595 I added ->sort('Created DESC')

$files = DataList::create($baseClass)->exclude('ClassName', 'Folder')->sort('Created DESC');

I'm going to submit this on Github as a suggested update