21310 Posts in 5739 Topics by 2604 members
General Questions
SilverStripe Forums » General Questions » [SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | ||
| Author | Topic: | 1386 Views |
-
Re: [SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup

2 September 2010 at 10:25am
Use :
static $default_sort = 'LastName ASC';
in your DataObject.
-
Re: [SOLVED] Trouble getting the DropDownField & array to work in getCMSFields_Popup

2 September 2010 at 10:50am
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:
<?php
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;
}}
?>
| 1386 Views | ||
| Go to Top |


