CKEditor displaying HTML tags in editor

后端 未结 2 1592
野的像风
野的像风 2021-02-11 03:24

I am using a CKEditor and saving content to a MySQL database. When trying to edit the content again in the editor, I am getting HTML tags displayed as text, for example:

相关标签:
2条回答
  • 2021-02-11 03:35

    It seems that CodeIgniter's func set_value() acts like htmlspecialchars() in some way. So if you are getting <any_tag> on CKEditor this workaround can help you. Change

    $ck_editor->editor("sec1_content", set_value('sec1_content', html_entity_decode($default_value)), $config);
    

    To this:

    $ck_editor->editor("sec1_content", html_entity_decode(set_value('sec1_content', $default_value)), $config);
    

    PoloRM
    Put html_entity_decode around set_value. The reason for this is obviously because the set_value method might not use the $default_value parameter but return the posted data instead.

    0 讨论(0)
  • 2021-02-11 03:44

    For people who might have the same issue with CodeIgniter/CKEditor:

    The way to resolve this issue and still use the CodeIgniter set_value() method is the following:

    $ck_editor->editor("sec1_content", set_value('sec1_content', html_entity_decode($default_value)), $config);
    

    Do this:

    $ck_editor->editor("sec1_content", html_entity_decode(set_value('sec1_content', $default_value)), $config);
    

    Put html_entity_decode around set_value. The reason for this is obviously because the set_value method might not use the $default_value parameter but return the posted data instead.

    Thank you coramba for making me realize my mistake.

    0 讨论(0)
提交回复
热议问题