Y
Y
YuliaQ2020-01-03 11:01:15
Yii
YuliaQ, 2020-01-03 11:01:15

TinyMCE in Yii2 - html tags are displayed after text formatting. How to fix?

Connected the TinyMCE widget to the form

<?= $form->field($model, 'content')->widget(TinyMce::className(), [
    'options' => ['rows' => 12],
    'language' => 'ru',
    'clientOptions' => [
        'plugins' => [
            'advlist autolink lists link charmap  print hr preview pagebreak',
            'searchreplace wordcount textcolor visualblocks visualchars code fullscreen nonbreaking',
            'save insertdatetime media table contextmenu template paste image'
        ],
        'toolbar' => 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image'
    ]
]) ?>

After text has been edited (for example, after applying italics or bold), the tagged text is displayed on the page.
More or less like this:
<p><em><strong>Хорошие</strong></em></p>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-01-04
@YuliaQ

This is called data formatting.
For flexible HTML formatting on the page or when saving, the Yii team implemented a special HTML Purifier helper. . It has a lot of different settings. You can see how to use Yii 1.0 as an example . Or read the official documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question