4

Whenever I set up a $has_many or $many_many relationship SilverStripe will create a corresponding tab in the top tab strip. I am creating a GridField, assigning it to a variable and injecting it into the main tab. This works fine but the 'Tiles' tab still remains even though it is empty.

$fields->addFieldsToTab('Root.Main',
    [
        ... Other fields ...,
        $tiles
    ]
);

I have tried $fields->removeByName('Tiles'); but that removes the tab and the field. Is there any way to remove the top tab and keep the field?

Main Tab (tiles gridfield down the bottom)

enter image description here

Tiles Tabs (empty)

enter image description here

3dgoo
  • 15,716
  • 6
  • 46
  • 58
nickspiel
  • 5,170
  • 6
  • 33
  • 48

1 Answers1

4

Remove the Tiles tab before the new Tiles GridField is added in:

$fields->removeByName('Tiles');

$fields->addFieldsToTab('Root.Main',
    [
        ... Other fields ...,
        $tiles
    ]
);
3dgoo
  • 15,716
  • 6
  • 46
  • 58