首页 > 解决方案 > 从页面中删除默认 HtmlEditorField

问题描述

有没有办法从 SilverStripe 4.2.2 的后端页面中删除/禁用默认的 HtmlEditorField(内容)?

标签: silverstripe-4form-fields

解决方案


从您的页面或页面的子类:

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

    $fields->removeByName('Root.Main.Content');

    return $fields;
}

或作为扩展:

class RemoveContentExtension extends \SilverStripe\ORM\DataExtension
{
    public function updateCMSFields(\SilverStripe\Forms\FieldList $fields)
    {
        $fields->removeByName('Root.Main.Content');
    }
}

并使用 YAML 配置将扩展应用到您的页面:

# File: app/_config/content.yml
MyPage:
  extensions:
    - RemoveContentExtension

推荐阅读