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.

Template Questions /

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

Problem with Using DropdownField in CMS


Go to End


2 Posts   2521 Views

Avatar
acefx

Community Member, 8 Posts

11 March 2009 at 7:04pm

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.

Avatar
ajshort

Community Member, 244 Posts

11 March 2009 at 7:45pm

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