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:

Customising the CMS /

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

HTML Text name now showing up


Go to End


2 Posts   1588 Views

Avatar
DanStephenson

Community Member, 116 Posts

31 January 2009 at 1:08pm

Hi everyone,

I am setting up my first SilverStripe template. I've created a page with 2 custom fields, Sidebar, and Sidebar Feature. In the CMS, I can see that these text areas have been created, but they don't have any labels on them, so the admin knows what to enter. What did I do wrong?

class Page extends SiteTree {
static $db = array(
'Sidebar' => 'HTMLText',
'SidebarFeature' => 'HTMLText'
);

static $defaults = array(
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Sidebar', new HTMLEditorField('Sidebar'), 'Sidebar');
$fields->addFieldToTab('Root.Content.Sidebar', new HTMLEditorField('SidebarFeature'), 'Sidebar Feature');
return $fields;
}
}

Avatar
dio5

Community Member, 501 Posts

1 February 2009 at 3:34am

Your order of parameters is a bit wrong:

try:

$fields->addFieldToTab('Root.Content.Sidebar', new HTMLEditorField('Sidebar', 'Sidebar'));
$fields->addFieldToTab('Root.Content.Sidebar', new HTMLEditorField('SidebarFeature', 'Sidebar Feature'));

The argument you would put in where you had it originally, is to tell the Tab before which other field the new field should be inserted.

Hope this helps.