FriendsOfSymfony / FOSCKEditorBundle

Provides a CKEditor integration for your Symfony project.
Other
521 stars 84 forks source link

Required field not rendered #120

Closed rbrlortie closed 6 years ago

rbrlortie commented 6 years ago

Symfony 4 "friendsofsymfony/ckeditor-bundle": "^1.1"

It seems that this issue https://github.com/egeloen/IvoryCKEditorBundle/issues/305 is back / present on this version of the bundle.

kunicmarko20 commented 6 years ago

Based on comments it seems that it is a problem with ckeditor and not with the bundle.

kunicmarko20 commented 6 years ago

Closing as no reply.

StanislavUngr commented 5 years ago

My fix is to extend default twig template and append javascript that adds 'required' attribute after a CKEditor field is processed/rendered.

# config.yml

twig:
    form_themes:
        - 'Form/ckeditor_widget.html.twig'
# Form/ckeditor_widget.html.twig

{% extends 'FOSCKEditorBundle:Form:ckeditor_widget.html.twig' %}

{% block ckeditor_widget_extra %}
    {% if required %}
        CKEDITOR.on('instanceReady', function(){
            $('#{{ id }}').attr('required', true);
        });
    {% endif %}
{% endblock %}