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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

HTML Text name now showing up


Go to End


2 Posts   2019 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.