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.

Customising the CMS /

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

BUG : removeFieldFromTab needs to be _AFTER_ addFieldToTab()


Go to End


3 Posts   2490 Views

Avatar
Fuzz10

Community Member, 791 Posts

28 January 2009 at 5:56am

Hi,

It seems that in 2.3 , a strict order has to be followed within getCMSFields(). This worked in 2.2 and is very upgrade-unfriendly.

Can anyone please confirm that this is indeed a bug and happens for them as well ? If so , I'll create a new ticket for it.

;-)

This works :

function getCMSFields() {
		$fields = parent::getCMSFields();	
		$fields->addFieldToTab('Root.Content.Main', new ImageField('Screenshot'), 'Content');

		$fields->removeFieldFromTab("Root.Content.Main","Thumbnail"); 
		$fields->removeFieldFromTab("Root.Content.Main","Summary");
		$fields->removeFieldFromTab("Root.Content.Main","Content");

		return $fields;
}

while this does not :

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

		$fields->removeFieldFromTab("Root.Content.Main","Thumbnail"); 
		$fields->removeFieldFromTab("Root.Content.Main","Summary");
		$fields->removeFieldFromTab("Root.Content.Main","Content");

		$fields->addFieldToTab('Root.Content.Main', new ImageField('Screenshot'), 'Content');

		return $fields;
}

Avatar
dio5

Community Member, 501 Posts

28 January 2009 at 7:33am

Hi Fuzz10,

couldn't this just be because you're removing 'Content' first while you're adding one 'before Content' after that?

Is the bug there as well as you leave out 'Content' in your addFieldToTab?

Avatar
Fuzz10

Community Member, 791 Posts

28 January 2009 at 9:58am

ohww..daamn... I'm blind...

;)

I cannot try right now ... But I bet that is it... haha..

Thanks !