In Drupal 8 I have a form element fo type text_format, and I need to render it in a twig, but keeping the same format was entered in the WYSYWIG editor. I need to know how to render this element form, keeping the format? this its done in a custom form.

$form['template'] = [
  '#type' => 'text_format',
  '#title' => 'My title',
  '#rows' => 100,
  '#cols' => 120,
  '#format' => 'full_html',

1 Answer 1


The solution is render it using the #type => processed_text. That's it, then you will see the element renderd keeping the format used in WYSYWIG.

$elements = [
  '#type' => 'processed_text',
  '#text' => $data,
  '#format' => 'full_html',
  '#langcode' => 'en',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.