Jump to:

5554 Posts in 1742 Topics by 1227 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Order field before fieldset in CMS admin

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

Page: 1
Go to End
Author Topic: 2314 Views
  • Derek
    Avatar
    Community Member
    6 Posts

    Order field before fieldset in CMS admin Link to this post

    I want to place some fields in the Security tab under Members before the Search and Member List section. They get added the the Group table and then appear after the Member List section. Here is my code so far:

    class GroupDecorator extends DataObjectDecorator
    {
    function extraStatics()
    {
    return array('db' => array(
    'Email' => 'Varchar(255)',
    'Website' => 'Varchar(255)'));
    }
    public function updateCMSFields(Fieldset & $fields)
    {

    $fields->addFieldToTab('Root.Members', new TextField('Email', 'Email'));
    $fields->addFieldToTab('Root.Members', new TextField('Website', 'Website'));
    return $fields;
    }
    }

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Order field before fieldset in CMS admin Link to this post

    You can use the insertBefore() function rather than push to insert before a given field name (http://api.silverstripe.org/2.4/forms/fields-structural/FieldSet.html#methodinsertBefore) which is useful for inserting new tabs. For fields you can use the addFieldsToTab() with the optional 3 argument filled out with the field you want it to sit before (http://api.silverstripe.org/2.4/forms/fields-structural/FieldSet.html#methodaddFieldToTab)

  • Derek
    Avatar
    Community Member
    6 Posts

    Re: Order field before fieldset in CMS admin Link to this post

    Thanks for your response.
    I did see those parameters for addFieldsToTab() but in this case I don't see what field I'm putting it before. For the default layout of the Groups/Members page there is a search and then a members list. I want to put the new fields before this and after the Title (Group name)

  • Derek
    Avatar
    Community Member
    6 Posts

    Re: Order field before fieldset in CMS admin Link to this post

    I took a guess and this works:
    $fields->addFieldToTab('Root.Members', new TextField('Email', 'Email'), 'Members');
    $fields->addFieldToTab('Root.Members', new TextField('Website', 'Website'), 'Members');

    My new fields of 'email' and 'website' now appear before the members search and list section.

    2314 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.