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.

General Questions

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

[SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup


10 Posts   1766 Views


2 September 2010 at 10:25am Community Member, 271 Posts

Use :

static $default_sort = 'LastName ASC';

in your DataObject.


2 September 2010 at 10:50am Community Member, 34 Posts

Legend!! I spent a few hours trying to figure that out yesterday and with your help done in under an hour - thanks heaps :)

Code below:


class Staff extends DataObject {

static $default_sort = 'LastName ASC';

static $db = array(
'FirstName' => 'Text',
'LastName' => 'Text',
'Email' => 'Text',
'Location' => "Enum('Wellington,Auckland,Christchurch,London','Wellington')",
'JobTitle' => 'Text',
'JobDescription' => 'Text',

static $has_one = array(
'Page' => 'StaffPage',
'StaffProfileImage' => 'CustomImage',

static $fields = array(
'FirstName' => 'FirstName',
'LastName' => 'LastName',
    'Location' => 'Location',
'Email' => 'Email',
'JobTitle' => 'JobTitle',
'JobDescription' => 'JobDescription',

public function getCMSFields_forPopup() {
$fields = new FieldSet();

$fields->push(new TextField('FirstName', 'First name'));
$fields->push(new TextField('LastName', 'Last name'));
$fields->push(new DropDownField('Location', 'Location', singleton('Staff')->dbObject('Location')->enumValues()));
$fields->push(new TextField('Email'));
$fields->push(new TextField('JobTitle', 'Job Title'));
$fields->push(new TextareaField('JobDescription', 'Job Description - write a couple of paragraphs to describe your role at CDP.'));
$fields->push(new ImageField('StaffProfileImage', 'Staff profile image'));

   return $fields;