CKeditor doesn't work in controller response within a default theme In a Drupal 8 project I've a controller which returns a form that contains a text_format field.

CKeditor is working perfectly in my administration theme (Stable), but it does not on the default theme.

I've tried to attach ckeditor core module libraries to the controller returned response with no results.

The role which I test with has permissions "Use simple HTML text format", "Use full HTML text format", also the role is checked on /admin/config/content/formats/manage/basic_html also on /admin/config/content/formats/manage/full_html.

my_module/src/Controller/MyController.php :

&lt;?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\user\Entity\User;

/**
 * Provide user form.
 */
class MyController extends ControllerBase {

  /**
   * Return page content.
   */
  public function content() {
    // Load user edit form.
    $entity = User::load(\Drupal::currentUser()-&gt;id());
    $formObject = \Drupal::entityTypeManager()
      -&gt;getFormObject('user', 'default')
      -&gt;setEntity($entity);
    $form = \Drupal::formBuilder()-&gt;getForm($formObject);
    $render = \Drupal::service('renderer');
    $render_form = $render-&gt;renderPlain($form);
    return [
      '#theme' =&gt; 'customize_user_form',
      '#form' =&gt; $render_form,
      '#attached' =&gt; [
        // Attach ckeditor core module libraries.
        'library' =&gt; [
          'ckeditor/drupal.ckeditor',
          'ckeditor/drupal.ckeditor.stylescombo.admin',
          'ckeditor/drupal.ckeditor.admin',
          'ckeditor/drupal.ckeditor.plugins.drupalimagecaption',
        ],
      ],
    ];
  }

}


Results: 



Any suggestions?

Many thanks.
A form usually contains all libraries necessary, but you shouldn't render the form at this point in the controller.

Put it unrendered in the template variable

return [
  '#theme' =&gt; 'customize_user_form',
  '#form' =&gt; $form,
];


and when you print the form in the template {{ form }} the libraries should be attached automatically to the page.