Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Headline for CMS Field

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

Page: 1
Go to End
Author Topic: 1189 Views
  • OscarGodson
    Community Member
    9 Posts

    Headline for CMS Field Link to this post

    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;

  • Liam
    Community Member
    470 Posts

    Re: Headline for CMS Field Link to this post

    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');


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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.