This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w
3 Posts 893 Views
17 September 2011 at 10:51am
I am creating a form and I want to populate the DropdownField with items stored in a Product DataObject. I pretty much have it working but need to access the "Option" field which is the second field and not the "Name" field which is the first field.
I am using this
$Options = array('' => 'Please select') + DataObject::get('Product', "$this->ID",'Option')->toDropdownMap();
$f = new FieldSet(
new DropdownField('Color','Select Colour',$Options)
17 September 2011 at 2:48pm
You might want to use this instead then.
Dataobject::get("MyObject")->map("ID", "Title", "Please Select")
See more: http://www.ssbits.com/tutorials/2010/dynamically-generating-a-dropdown-list/
21 September 2011 at 3:42pm
That did the trick, that link had exactly the information I needed. Thanks for the help.