Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Problem with Using DropdownField in CMS

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

Page: 1
Go to End
Author Topic: 1454 Views
  • acefx
    Avatar
    Community Member
    8 Posts

    Problem with Using DropdownField in CMS Link to this post

    Hi

    Trust me, it took me days to figure this out but if i have the headache on that, then someone else might probably be having same.

    But here is how it worked:

    In the
    static $db = array(

       'Issu' => "Enum('One, Two, Three','One')",

    );

    and in the :

    function getCMSFields()
    {
          $fields = parent::getCMSFields();
          
          $fields -> addFieldtoTab('Root.Content.Main', new DropdownField('Issu', 'Issue Type', Array('1'=>'One', '2'=>'Two', '3'=>'Three')));

          return $fields;
    }

    Just replace the One, Two, and Three with you titles and you can also continue the array. Its quite simple.

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: Problem with Using DropdownField in CMS Link to this post

    In your DropdownField constructor you should be using "$this->dbObject('Issue')->enumValues()" rather than the hard-coded array.

    1454 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.