Use :
static $default_sort = 'LastName ASC';
in your DataObject.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Use :
static $default_sort = 'LastName ASC';
in your DataObject.
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;
}
}
?>