5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1476 Views |
-
Order field before fieldset in CMS admin

4 April 2011 at 6:59am
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;
}
} -
Re: Order field before fieldset in CMS admin

4 April 2011 at 9:21am
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)
-
Re: Order field before fieldset in CMS admin

4 April 2011 at 11:44am
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) -
Re: Order field before fieldset in CMS admin

4 April 2011 at 1:09pm
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.
| 1476 Views | ||
|
Page:
1
|
Go to Top |


