Jump to:

791 Posts in 369 Topics by 303 members

Widgets

SilverStripe Forums » Widgets » Drop down list in getCMSFields

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 3493 Views
  • grilldan
    Avatar
    Community Member
    135 Posts

    Drop down list in getCMSFields Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Drop down list in getCMSFields Link to this post

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

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: Drop down list in getCMSFields Link to this post

    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?

  • JonoM
    Avatar
    Community Member
    103 Posts

    Re: Drop down list in getCMSFields Link to this post

    That helped me heaps, thanks so much UC.

  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Re: Drop down list in getCMSFields Link to this post

    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?

    3493 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.