Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » BUG : removeFieldFromTab needs to be _AFTER_ addFieldToTab()

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

Page: 1
Go to End
Author Topic: 1448 Views
  • Fuzz10
    Avatar
    Community Member
    787 Posts

    BUG : removeFieldFromTab needs to be _AFTER_ addFieldToTab() Link to this post

    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;
    }

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: BUG : removeFieldFromTab needs to be _AFTER_ addFieldToTab() Link to this post

    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?

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: BUG : removeFieldFromTab needs to be _AFTER_ addFieldToTab() Link to this post

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

    ;)

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

    Thanks !

    1448 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.