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.

Customising the CMS /

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

CMS field order


Go to End


3 Posts   1652 Views

Avatar
Faloude

Community Member, 55 Posts

28 January 2016 at 3:53am

Hi there. I've succesfully added an image upload field to the CMS. However, in the CMS it's displayed as the last field under the big "Content" field. I want it to be above the standard "Content" field and under the standard "Navigation Label" field. How can I re-arrange the CMS for this page type?

Custom CMS field code used:

class Page extends SiteTree {

	private static $db = array(
	);

	private static $has_one = array(
		'Header' => 'Image'
	);

	public function getCMSFields() {
         $fields = parent::getCMSFields();

         $fields->addFieldToTab('Root.Main', UploadField::create('Header'));
         
         return $fields;
    }

}

Avatar
Devlin

Community Member, 344 Posts

30 January 2016 at 1:57am

By using the third parameter of addFieldToTab($tabName, $field, $insertBefore = null).

So, "$fields->addFieldToTab('Root.Main', UploadField::create('Header'), 'Content');" should do the trick.

Avatar
Faloude

Community Member, 55 Posts

1 February 2016 at 4:29am

Thank you Devlin, that was easier than expected.

Found this for future reference: http://api.silverstripe.org/master/class-FieldList.html#_addFieldToTab