Remove default HtmlEditorField from Page

Silverstripe Version: 4.2.2

Is there a way to remove/disable the default HtmlEditorField (Content) from a Page in back-end from SilverStripe?

You can control what fields are shown in the CMS using the getCMSFields() method (along with a couple of others).

public function getCMSFields()
 {
   $fields = parent::getCMSFields();
   $fields->removeByName('Content');
   return $fields;
  }

The method would go in the relevant page class in your code, and it will remove the field from that class and any of its descendants. eg. If you add it to the default Page class, the field would be removed from all pages. If you add it to your own custom class (eg. class MyPage extends \Page { }) then only that class would be altered.

This lesson covers some of these topics in a bit more detail: https://www.silverstripe.org/learn/lessons/v4/adding-custom-fields-to-a-page-1

1 Like

Thank you, this works perfect!