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.

Customising the CMS

BUG : removeFieldFromTab needs to be _AFTER_ addFieldToTab()


Reply

3 Posts   1470 Views

Avatar
Fuzz10

28 January 2009 at 5:56am Community Member, 787 Posts

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

28 January 2009 at 7:33am Community Member, 501 Posts

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

28 January 2009 at 9:58am Community Member, 787 Posts

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

;)

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

Thanks !