Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Add a space in tab name


Go to End


6 Posts   2024 Views

Avatar
Big Bang Creative

Community Member, 92 Posts

18 March 2009 at 11:11pm

How do I add a space into the tab name? I have created a tabset and added some more tabs as below but I could really do with there been spaces in the tab names (parent & child).

<?php

class HomePage extends Page {
static $db = array(
'Box1Thumbnail' => 'HTMLText',
'Box1Link' => 'HTMLText',
'Box2Thumbnail' => 'HTMLText',
'Box2Link' => 'HTMLText',
'Box3Thumbnail' => 'HTMLText',
'Box3Link' => 'HTMLText',
'Box4Thumbnail' => 'HTMLText',
'Box4Link' => 'HTMLText'
);
static $has_one = array(
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root', new TabSet('HomePageBoxes'));
$fields->addFieldToTab('Root.HomePageBoxes.Box1', new HTMLEditorField('Box1Thumbnail', 'Thumbnail'));
$fields->addFieldToTab('Root.HomePageBoxes.Box1', new HTMLEditorField('Box1Link', 'Link'));
$fields->addFieldToTab('Root.HomePageBoxes.Box2', new HTMLEditorField('Box2Thumbnail', 'Thumbnail'));
$fields->addFieldToTab('Root.HomePageBoxes.Box2', new HTMLEditorField('Box2Link', 'Link'));
$fields->addFieldToTab('Root.HomePageBoxes.Box3', new HTMLEditorField('Box3Thumbnail', 'Thumbnail'));
$fields->addFieldToTab('Root.HomePageBoxes.Box3', new HTMLEditorField('Box3Link', 'Link'));
$fields->addFieldToTab('Root.HomePageBoxes.Box4', new HTMLEditorField('Box4Thumbnail', 'Thumbnail'));
$fields->addFieldToTab('Root.HomePageBoxes.Box4', new HTMLEditorField('Box4Link', 'Link'));

return $fields;
}
}
class HomePage_Controller extends Page_Controller {

}
?>

Avatar
Howard

Community Member, 215 Posts

19 March 2009 at 2:17pm

I take it you have tried just adding spaces? If that doesn't work then try it with double commas " not ' around the title.

Like:
$fields->addFieldToTab("Root.Home Page Boxes.Box1", new HTMLEditorField('Box1Thumbnail', 'Thumbnail'));

Any joy?

Avatar
Big Bang Creative

Community Member, 92 Posts

20 March 2009 at 3:59am

Yes I did try it with spaces lol and it did not work

Avatar
martimiz

Forum Moderator, 1391 Posts

22 March 2009 at 5:03am

Edited: 22/03/2009 5:05am

When I do this in my ContactForm page:

$fields->addFieldToTab('Root.Content.ContactForm', new TextField('Name', 'Name'));

the tab name will read 'Contact Form'. Tried this with other names as well - seems a space is added by using capitals (v2.3) Won't work with numbers I guess...

Avatar
Big Bang Creative

Community Member, 92 Posts

10 April 2009 at 2:36am

Your adding to "Content" which will put the text field under the content box which works fine. I am adding fields to a new tab which I still cannot get spaces in.

Avatar
bummzack

Community Member, 904 Posts

10 April 2009 at 2:52am

TabSet takes a second parameter upon construction that will be used as Title (if it's a string).

So, you could do the following:

$fields->addFieldToTab('Root', new TabSet('HPBoxes', 'Home Page Boxes'));
$fields->addFieldToTab('Root.HPBoxes.Box1', new HTMLEditorField('Box1Thumbnail', 'Thumbnail'));
...