Reputation: 2551
In SilverStripe's CMS I want to remove the Content
tab within a page. I can do this as follows:
$fields->removeFieldsFromTab('Root.Content.Main', 'Content');
I then want to create my own custom tab:
$fields->addFieldToTab('Root.Content.MyTab', $myField);
However by adding my own custom tab it brings the Content
tab back.
The other option is just to make MyTab
the default 'up' tab. Is that possible?
Upvotes: 2
Views: 2848
Reputation: 1
For Silverstripe 5.x:
$fields->removeFieldFromTab('Root.Main', 'Content');
Upvotes: 0
Reputation: 15794
To remove the Content
tab in SilverStripe 2.4:
$fields->removeFieldFromTab('Root.Content', 'Main');
And to add a field to a tab named MyTab
:
$fields->addFieldToTab('Root.Content.MyTab', $myField);
To remove the Content
tab in SilverStripe 3.1:
$fields->removeFieldFromTab('Root', 'Main');
And to add a field to a tab named MyTab
:
$fields->addFieldToTab('Root.MyTab', $myField);
Removing the Content
tab means you cannot control the page title.
removeFieldsFromTab
removes a number of fields from a Tab
/TabSet
within this FieldList
. It takes an array of field names as the second parameter.
removeFieldFromTab
removes a single field from a Tab
/TabSet
within this FieldList
. It takes a string field name as the second parameter.
In your case you want to use removeFieldFromTab
not removeFieldsFromTab
.
Upvotes: 9
Reputation: 20286
I know this question is old but I had same problem and I've figured it out.
In getCMSFields() method I wrote
$fields = parent::getCMSFields();
$fields->removeByName('XXX'); //this line removes tab
return $fields;
where 'XXX' is name of my tab 'Root.XXX'
I hope it'll help someone.
Upvotes: 3