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.

Customising the CMS /

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

Headline for CMS Field


Go to End
Reply


2 Posts   1412 Views

Avatar
OscarGodson

Community Member, 9 Posts

18 December 2008 at 12:34pm

I've been working on this for close to two hours. I've used SS many times before, but haven't needed to add a custom field. After an hour I got it to show a new HtmlEditorField, but there is no title set to the field when you look at it in the admin. It works and I can display the content on the page using both $Sidebar_Title and $Sidebar.

I have this and the TextField is showing what I have there, but the HtmlEditorField is not. P.S. this is in the Page class. Yes, i have gone through the tutorials as well about a dozen times :)

	static $db = array(
		'Sidebar_Title' => 'Text',
		'Sidebar' => 'HTMLText'
	);

function getCMSFields() {
	$fields = parent::getCMSFields();

	$fields->addFieldToTab('Root.Content.Main', new TextField('Sidebar Title'), 'Content');
	$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Sidebar'), 'Content');

   return $fields;
}

Avatar
Liam

Community Member, 470 Posts

18 December 2008 at 6:29pm

For starters, don't use underscores in your variables. Bad naming conventions for SS.

And just add a comma after the name for the title.

So like this:

$fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Sidebar', 'Some Title'), 'Content');

Cheers,

p.s always look through the api documentation so you can see how everything works in more detail.