Tab order

silverstripe-4
Tags: #<Tag:0x00007f10d2e44898>

#1

Silverstripe Version: 4.3

Question:

I have a tab I would like to place directly after the Content tab within the Admin section of the site. I can achieve this with the following code;

$fields->insertAfter(new Tab('Root.BackgroundInformation', 'Background information'), 'Main');

However, I would like to add some tabs within the ‘Background information’ tab. I have tried using the following code;

$fields->addFieldToTab('Root.BackgroundInformation.General', TextField::create('Students','Year level')
    ->setDescription('Year level/s best suited to (e.g. Year 5 or Years 5 to 12)'
));

But this breaks the admin section when I refresh the page.

The only way I seem to be able to have tabs within a tab is with;

$fields->findOrMakeTab('Root.BackgroundInformation.General', 'General');
$fields->findOrMakeTab('Root.BackgroundInformation.ClassroomActivity', 'Classroom activity');
$fields->findOrMakeTab('Root.BackgroundInformation.UnitOfWork', 'Unit of work');
$fields->findOrMakeTab('Root.BackgroundInformation', 'Background information');

$fields->addFieldToTab('Root.BackgroundInformation.General', TextField::create('Students','Year level')
    ->setDescription('Year level/s best suited to (e.g. Year 5 or Years 5 to 12)'
));

...

Problem is, this does not allow me to place the tab after the ‘Content’ tab.

Can someone please help with a solution to this.

Thanks


#2

Maybe try:
$fields->addFieldsToTab(‘main’,[ Field1, Field2, Field3 ]);


#3

Thank you for your response. Although this does allow me to clean up my field placement, I am still unable to place the ‘Background information’ tab directly after the ‘Content’ tab.