4

Searched high and low for the answer to this, but it seems noone else is having it or really worries about it. Here's the issue:

  • Class A has a getCMSFields() method that adds a tab called ‘Root.SEO’ with some fields in it.
  • Class B inherits from Class A and has a getCMSFields() method of it's own that first calls $fields = parent::getCMSFields() and adds further fields/tabs to $fields.
  • SEO tab is always before anything set in Class B, as Class A executes first. But I'd like it to be somewhere between two tabs defined by Class B

I tried $fields->removeByName('SEO') and they re-adding the tab in Class B manually. Which would be fine, but I can't seem to find a way to get hold of the SEO tab's content before removing it. So the best I can do is correctly position an empty SEO tab with no fields from Class A.

scrowler
  • 24,273
  • 9
  • 60
  • 92
Aaryn
  • 1,601
  • 2
  • 18
  • 31

1 Answers1

4

One way to do this is to remove the SEO tab and add it back in after adding our other fields and tabs:

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

    // Add fields here

    if ($seoTab = $fields->fieldByName('Root.SEO')) {
        $fields->removeFieldFromTab('Root', 'SEO');
        $fields->fieldByName('Root')->push($seoTab);
    }
}
3dgoo
  • 15,716
  • 6
  • 46
  • 58