ckeditor: how to encapsulate rendering?

Viewed 23

Please excuse my English (google translate). I am using FOSCKEditorBundle with easyadmin 4. For my rendering to be really identical to that of my site, the value of the textarea must be surrounded by two divs, like this:

<section id="sectInterne">
   <article class="artInterne">
       {{ value }}
   </article>
</section>

To test, I modified the ckeditor_widget.html.twig file and it works fine as I want. Of course this is not the right method, since the added code is saved in db when I save and in addition my modification would be overwritten during updates. So how could I encapsulate the content of my textarea in html code ?

Thank you for your help

1 Answers

not sure if I understood your problem correctly but :

If you want to display the html from your database you can use

{{ value|raw }}

If you want to store the text in your database you can use a dedicated CkeditorType in your formtype.

use FOS\CKEditorBundle\Form\Type\CKEditorType;

$builder->add('field', CKEditorType::class, array(
    'config' => array(
        'uiColor' => '#ffffff',
        //...
    ),
));```
Related