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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

How Do I Remove DOM CMS Tabs


Go to End


6 Posts   4638 Views

Avatar
socks

Community Member, 191 Posts

10 January 2011 at 7:06pm

I've added DataObject Manager to my Page.php as it applies to most all classes. I'd like to remove it from one class.

I assumed I should use a DataObject Decorator and have successfully removed other tabs from the CMS (ie Content.Metadata) this way, but haven't been able to figure out how to remove the tab I created w/ DOM on my Page.php.

Any help is much appreciated.
Thanks

Avatar
Dr0gaz

Community Member, 37 Posts

11 January 2011 at 1:36am

Hi !!

try this:

//Remove Fields
$f->removeFieldFromTab("Root.Content.Main","Content");
$f->removeByName("Behaviour");
$f->removeByName("Content");
$f->removeByName("Access");
$f->removeByName("To-do");

//$f->removeFieldFromTab("Root.Content", "Meta-data");
//$f->removeFieldFromTab("Root.Content", "Main");
//$f->removeFieldFromTab("Root.Content","GoogleSitemap");
//$f->removeFieldFromTab('Root', 'Beahvior'); // replace the tab with MMDOM tab

Avatar
socks

Community Member, 191 Posts

11 January 2011 at 3:37pm

Edited: 11/01/2011 3:39pm

Yeah, I tried both of those but neither worked. To clarify, this is what I have:

Page.php

…
// SIDEBAR IMAGES
	$manager = new ImageDataObjectManager(
		$this, // Controller
		'SidebarImages', // Source name
		'SidebarImage', // Source class
		'Attachment', // File name on DataObject
		array(// Headings 
		),
		'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
		// Filter clause
		// Sort clause
		// Join clause
	);
	$manager->setAddTitle('Image');
	$manager->allowUploadFolderSelection();
	$fields->addFieldToTab('Root.Content.SidebarImages', $manager);
…

Trying to remove the tab Sidebar Images from above in DataObjectDecorator below:
CustomBlaBlaPage.php

<?php

class CustomBlaBlaPage extends DataObjectDecorator {
	
	public function getCMSFields() {
	   $fields = parent::getCMSFields();
	   $this->extend('updateCMSFields', $fields);
	   return $fields;
	}
	
	public function updateCMSFields(FieldSet $fields) {
		$fields->removeFieldFromTab('Root.Content','Metadata'); // THIS WORKS
		$fields->removeFieldFromTab('Root.Content','GoogleSitemap'); // THIS WORKS
                $fields->removeFieldFromTab('Root.Content','SidebarImages'); // THIS DOESN'T WORK
	}

}

Maybe I'm not going about it the right way.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

11 January 2011 at 4:21pm

You're using this method wrong:

$fields->removeFieldFromTab('Root.Content','SidebarImages'); // THIS DOESN'T WORK

Use either:

$fields->removeFieldFromTab('Root.Content.SidebarImages','SidebarImages');

or, just:

$fields->removeByName('SidebarImages');

Avatar
socks

Community Member, 191 Posts

12 January 2011 at 4:07pm

I tried both of those as well and no go. I can easily remove SidebarImages if it's another class that extends Page, but when it extends Dataobject Decorator, it doesn't work.

Thanks

Avatar
Lou

Community Member, 8 Posts

18 February 2013 at 9:40pm

Edited: 18/02/2013 9:57pm

....and two years later, I stumbled into the same problem.
I cannot seem to remove fields from decorators. Is this a bug? I'm using version 2.4.7. Can anyone point me in the right direction?

:: I created a post for my query: http://www.silverstripe.org/data-model-questions/show/22646