Jump to:

5541 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding new fields (after Content field)

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

Page: 1
Go to End
Author Topic: 3258 Views
  • ootersplace
    Avatar
    Community Member
    16 Posts

    Adding new fields (after Content field) Link to this post

    I think I'm missing something obvious, but as per Tutorial 2, to add new fields to the CMS, you write:

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

    $fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
    $fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
       
    return $fields;
    }

    This works, but all the fields are added before the "Content" field. Is there a way to re-order them so that the Content field shows up first in the CMS, and all the other fields underneath that one?

    Thanks for any help!

    Karl.

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Adding new fields (after Content field) Link to this post

    Welcome to Silverstripe !

    That is because your new field will be added before content (last parameter)....

    API-DOC
    void addFieldToTab (string $tabName, FormField $field, [string $insertBefore = null])

    * string $tabName: The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab. This function will create any missing tabs.
    * FormField $field: The FormField object to add to the end of that tab.
    * string $insertBefore: The name of the field to insert before. Optional.

  • ootersplace
    Avatar
    Community Member
    16 Posts

    Re: Adding new fields (after Content field) Link to this post

    Thank you -- I knew it was something that was staring me in the face! Removing 'Content' made everything better.

    And thanks for the welcome!

    3258 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.