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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Widgets /

Discuss SilverStripe Widgets.

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

Drop down list in getCMSFields

Go to End

5 Posts   4342 Views


Community Member, 135 Posts

3 February 2009 at 9:35am

I am trying to get a drop down list of all the folders under assets. I think I need to do something with enum(?) but I am not sure where to go with it. Could anyone give me a pointer? Thank you :)


Forum Moderator, 4102 Posts

3 February 2009 at 10:56am

$fields->addFieldToTab("Root.Content.Main", new DropdownField('Folders','Choose a folder', DataObject::get("Folder")->toDropdownMap()));


Community Member, 135 Posts

3 February 2009 at 5:53pm

Let me explain a little bit more. I am making a custom widget for one of my sites. With the widget permitted members will be able to upload files directly to the the chosen folder (The folder will be chosen by the admin, when the widget is added to the page.). I need to be able to get a drop down list as a select/option in the admin section for the admin to choose which folder the uploads will be to.

Thank you for the above code, but I'm not sure if that's what I am looking for or not. Where would that go?


Community Member, 130 Posts

3 February 2010 at 2:03am

That helped me heaps, thanks so much UC.


Community Member, 80 Posts

14 October 2010 at 1:29pm

Uncle Cheese:

How would you do this for picking an image within the folders. Like the image picker works in the WYSIWYG within the content field?