• Reset your password
Home
OO PHP, Drupal, Symfony Developer and Architect
Tim Rabbetts

Main navigation

  • Home
  • Blog
  • Log in

Drupal 8: embed entity wysiwyg custom form and then render the value in another form.

Breadcrumb

  • Home
  • blog
  • drupal 8 embed entity wysiwyg custom form and then render the value in another form
  • Drupal 8: embed entity wysiwyg custom form and then render the value in another form.
Tim
Rabbetts
By zarexogre | Thu, 02/04/2020
technology, keyboard, computing
drupal

Its possible to easily embed entites into the Drupal 8 wysiwyg editor, however, I have a custom form and when I rendered it in another form it didnt render correctly.  The reason was I used markup not processed_text field type.

So the original settings form where I add my markup and entity ref is built like this:

$form['intro_text'] = [
  '#type' => 'text_format',
  '#format' => \Drupal::state()->get('myid')['format'],
  '#title' => t('Intro text'),
  '#default_value' => \Drupal::state()->get('myid')['value'],
];

Then in another form to show this text I do this:

$form['output_markup'] = [
  '#type' => 'processed_text',
  '#text' => \Drupal::state()->get('myid')['value'],
  '#format' => \Drupal::state()->get('myid')['format'],
];