0

I have a modal for the modification of a entity in my project. When I put data in the modal, only the CKeditor field is empty.

I have tested different solutions but so far none of them work. I checked, the data I want to put in the CKEditor field is not null or non-existent.

Thank you for your help.

Ajax :

function ($) {
function remplirFormSociete(modal,reponse){
    alert(reponse['INFO']);
            modal.find('input#edit_form_Id').val(reponse['Id']);
            modal.find('input#edit_form_NOM').val(reponse['NOM']);
            modal.find('select#edit_form_CATEGORIES').val(reponse['CATEGORIES']);
            modal.find('input#edit_form_INFO').val(reponse['INFO']);
            modal.find('input#edit_form_HOST').val(reponse['HOST']);
            modal.find('input#edit_form_NOM_USER').val(reponse['NOM_USER']);
            modal.find('input#edit_form_MDP').val(reponse['MDP']);
    }

    $(document).ready(function(){  

        //Lorsque l'utilisateur édit un employé temporaire
        $('#EditSociete').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget) // Button that triggered the modal
            var recipient = button.data('whatever') // Extract info from data-* attributes
            var modal = $(this);
            if(recipient){
                $.ajax({
                    url: BaseURL+"/societe/ajax/Societe",
                    method: "post",
                    data: {Id:recipient},
                    success :  function(reponse)  {
                        remplirFormSociete(modal,reponse[recipient]);
                     }
                });
            } else {
                var reponse = [];reponse['Id']='';reponse['CATEGORIES']='';reponse['INFO']='';reponse['HOST']='';reponse['NOM_USER']='';reponse['MDP']='';
                remplirFormSociete(modal,reponse);
            }
        });
    }); 
}) (jQuery);

in the form :

 ->add('INFO',           CKEditorType::class, array('attr'       => array('class' => "form-control"),
                                                            'label'             => 'Information :',
                                                            'required'          => false,
                                                            'label_attr'        => array('class' => 'col-md-2 control-label')))
Verdouze
  • 417
  • 2
  • 9
  • 25

1 Answers1

2

I think this will resolve your problems:

CKEDITOR.instances.editor1.setData( '<p>This is the editor data.</p>' );

reference

DarkBee
  • 16,592
  • 6
  • 46
  • 58