Jump to:

22992 Posts in 11842 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Replace CMS field name and change field type

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

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

Page: 1
Go to End
Author Topic: 445 Views
  • vxd
    Avatar
    Community Member
    16 Posts

    Replace CMS field name and change field type Link to this post

    I've searched the docs but couldn't find it.

    I want to change the name of the CMS field "Content" to something else and also change the HtmlEditorField to a textField.

    Thanks

  • kinglozzer
    Avatar
    Community Member
    138 Posts

    Re: Replace CMS field name and change field type Link to this post

    The easiest way to do it is in your Page class getCMSFields(), untested:

    public function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->removeByName('Content'); // Might be 'Root.Content' or 'Root.Main.Content', not sure which
    $fields->insertAfter(new TextField('Content', 'Your Field Name'), 'MenuTitle');
    return $fields;
    }

    'Content' has a data type of 'HTMLText', but I think you should be okay to save standard text input into it. Not sure how to change its datatype if not.

    445 Views
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.