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.

Widgets /

Discuss SilverStripe Widgets.

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

Drop down list in getCMSFields


Reply


5 Posts   3605 Views

Avatar
grilldan

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 :)

Avatar
UncleCheese

Forum Moderator, 4093 Posts

3 February 2009 at 10:56am

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

Avatar
grilldan

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?

Avatar
JonoM

Community Member, 103 Posts

3 February 2010 at 2:03am

That helped me heaps, thanks so much UC.

Avatar
Hello_electro

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?