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

1 Answer 1

4

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

$fields->removeByName('Tiles');

$fields->addFieldsToTab('Root.Main',
    [
        ... Other fields ...,
        $tiles
    ]
);
1
  • 1
    So simple... i feel like i tried everything but that! Thanks for the fix :)
    – nickspiel
    Feb 11, 2016 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.