0

我是 silverstripe 的初学者,我不知道如何解决这个问题。在文档中也找不到任何内容。

我添加了 HTMLText 字段(那个 tinymce 编辑器),一切似乎都正常。数据在网络上保存和提供,但数据并不丰富。它也呈现 html 标签。如何改变它?

谢谢。

4

1 回答 1

0

It would be helpful if you posted some code snippets of the approach you have taken so we can see where you might have gone wrong. So, I'm going to take a guess here: did you make the data-field an HTMLText field? For example: if I want to use $TextBlock in my template as HTML, then I would need to save it as HTMLText and use HTMLEditorField in the CMS. If I would save it as Text or Varchar I would get unexpected results. See: https://docs.silverstripe.org/en/4/developer_guides/forms/field_types/htmleditorfield/#rich-text-editing-wysiwyg

use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\ORM\DataObject;

class MyObject extends DataObject 
{
    
    private static $db = [
        'TextBlock' => 'HTMLText'
    ];
    
    public function getCMSFields() 
    {
        return new FieldList(
            HTMLEditorField::create('TextBlock')
        );
    }
}
于 2021-02-25T19:29:09.883 回答