egeloen / IvoryCKEditorBundle

Provides a CKEditor integration for your Symfony project.
MIT License
336 stars 114 forks source link

Add async support #219

Closed egeloen closed 8 years ago

egeloen commented 8 years ago

This PR tries to fix #212 by allowing to load CKEditor at the bottom of the page as it is done in GenemuFormBundle or DatetimepickerBundle.

How does it work?

First, you need to install the IvoryFormExtraBundle which provides javascript/stylesheet form fragments.

Second, you need to configure your form as async in order to render it latter with a new twig function (PHP templating is also supported):

ivory_ck_editor:
    autoload: false
    async: true

Then, update your template in order to look like the following:

{% extends '::base.html.twig' %}

{% block body %}
    {{ form(form) }}
{% endblock %}

{% block javascripts %}
    <script type="text/javascript" src="{{ asset('bundles/ivoryckeditor/ckeditor.js') }}"></script>
    {{ form_javascript(form) }}
{% endblock %}

Enjoy!