Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Bundles
  4. FOSCKEditorBundle
  5. Manage CKEditor loading
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Load CKEditor manually
  • Load CKEditor asynchronously

Manage CKEditor loading

Edit this page

Manage CKEditor loading

By default, in order to prototype your form really fast, the bundle loads the CKEditor library each time you declare a CKEditor form. Basically, it means that if you have three CKEditor fields in your form, then, there will be three CKEditor library loadings.

Load CKEditor manually

If you want to control the CKEditor loading, you can configure the bundle to not load the library at all and let you the control of it. To disable the CKEditor library loading, you can do it globally in your configuration:

1
2
3
# app/config/config.yml
fos_ck_editor:
    autoload: false

Or you can disable it in your widget:

1
$builder->add('field', 'ckeditor', array('autoload' => false));

Note

If you use this approach, be aware CKEditor must be loaded before any fields have been rendered, so we recommend you to register it in the <head> of your page.

Load CKEditor asynchronously

If you want to load CKEditor at the bottom of your page, the best way is to still disable the CKEditor loading (in order to let you load CKEditor at the bottom of the page only one time) but also to configure the bundle to render the javascript latter with a dedicated function shipped in a third party bundle named IvoryFormExtraBundle.

So, first you need configure the bundle. You can do it globally in your configuration:

1
2
3
4
# app/config/config.yml
fos_ck_editor:
    autoload: false
    async: true

Or you can configure it in your widget:

1
2
3
4
$builder->add('field', 'ckeditor', array(
    'autoload' => false,
    'async'    => true,
));

Then, install the third party bundles as explained in its documentation.

Finally, in your Twig template, you can render the form javascript with:

1
{{ form_javascript(form) }}

Or if you use the PHP templating engine:

1
<?php echo $view['ivory_form_extra']->javascript($form) ?>

Note

If you use this approach, be aware CKEditor must be loaded before you render the form javascript.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    No stress: we've got you covered with our 116 automated quality checks of your code

    No stress: we've got you covered with our 116 automated quality checks of your code

    Code consumes server resources. Blackfire tells you how

    Code consumes server resources. Blackfire tells you how

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of George Yiannoulopoulos, a Symfony contributor

    Thanks George Yiannoulopoulos for being a Symfony contributor

    2 commits • 36 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Meilisearch