首页 > 解决方案 > 如何在 Yii2 中使用 Froala 所见即所得编辑器在保存内容时禁用 html 编码?

问题描述

我在 Yii2 应用程序中使用了 Froala 编辑器。在将内容保存到数据库列问题时,它会添加 HTML 标记。如何禁用该选项,我只想按原样保存内容?

 <?php echo froala\froalaeditor\FroalaEditorWidget::widget([
        'model' => $model,
        'attribute' => 'question',
        'options' => [
            // html attributes
            'id'=>'question'
        ],
        'clientOptions' => [
            'toolbarInline' => false,
            'theme' => 'royal', //optional: dark, red, gray, royal
            'language' => 'en_gb' // optional: ar, bs, cs, da, de, en_ca, en_gb, en_us ...
        ]
    ]); ?>

标签: yii2froala

解决方案


尝试这个:

<?php echo froala\froalaeditor\FroalaEditorWidget::widget([
    'model' => $model,
    'attribute' => 'question',
    'options' => [
        // html attributes
        'id'=>'question'
    ],
    'clientOptions' => [
        'toolbarInline' => false,
        'theme' => 'royal', //optional: dark, red, gray, royal
        'language' => 'en_gb',
        'entities' => '', // <- this
    ]
]); ?>

https://www.froala.com/wysiwyg-editor/docs/options#entities


推荐阅读