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.

Data Model Questions /

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

How can I order the fields within a dataobject?


Go to End


1233 Views

Avatar
SevenSquared

Community Member, 1 Post

13 April 2010 at 12:40am

Hi Can anyone tell me how I can order the fields for display within a DataObject? I want the SiteTree field to appear above the 'NoLink' field, but it always appears at the bottom. Here is my DataObject Code...

class ClientResource extends DataObject
{
static $db = array (
'Name' => 'Varchar(255)',
'NoLink' => 'Boolean',
'Category' => "Enum('General, Public, Digital')"

);

static $has_one = array (
'HomePage' => 'HomePage',
'ClientUrl' => 'SiteTree'
);

public function getCMSFields_forPopup()
{
return new FieldSet(

new TextField('Name'),

new TreeDropdownField('ClientUrlID', 'Choose a page to link to:', 'SiteTree'),

new CheckboxField('NoLink'),

new DropdownField('Category','Category', singleton('ClientResource')->dbObject('Category')->enumValues())

);
}
}