2017-12-13 1 views
0

먼저 CKeditor로 내 문제를 해결할 수있는 사람이 있는지 알 수 없습니다.CKedit 데이터가 PHP 유효성 검사에서 인식되지 않음 Codeigniter

내 컨트롤러 코드 :

 public function reply_topic() 
    { 
     $this->load->helper('form'); 
     $this->load->library('form_validation'); 

     $this->form_validation->set_rules('comment', 'Comment Field Required', 'required'); 
     //$this->form_validation->set_rules('g-recaptcha-response', 'recaptcha validation', 'required|callback_validate_captcha'); 
     //$this->form_validation->set_message('validate_captcha', 'Please check the the captcha form'); 

     if ($this->form_validation->run() == FALSE) 
     { 
      $this->load_reply_to_topic_view($this->input->post('topic_id')); 
     } 
     else 
     { 
      $topic_id = $this->input->post('topic_id'); 
      $this->topic_model->postReplyTopic(); 
      echo '<div class="alert alert-success">'.lang_key('reply_submited').'</div>'; 
      $this->load_reply_to_topic_view($topic_id=''); 
     } 
    } 

이 코드는 작업 벌금을 시작하는 문제가 발생하지 않습니다. 그러나 데이터를 제출할 때 항상 오류가 발생합니다. 처럼 댓글 입력란에 이미 데이터를 입력했지만이 비어 있습니다.이 오류는 내가 CKeditor를 사용하고있을 때 나타납니다. 하지만 난 단지 일반 텍스트 영역을 사용하면 정말 잘 작동합니다. 여기

<!-- Javascript --> 
<script type="text/javascript"> 
CKEDITOR.replace('comment'); 
</script> 

그리고

는 코멘트 섹션 실제로 텍스트 영역 필드를 사용하지 않는

<script type="text/javascript"> 
var loadUrl = '<?php echo base_url("threads/load_reply_to_topic_view/".$item['id']);?>'; 
    jQuery.post(
     loadUrl, 
     {}, 
     function(responseText){ 
      jQuery('.reply-topic-form-holder').html(responseText); 
      init_reply_topic_js(); 
     } 
    ); 



function init_reply_topic_js() 
{ 
    jQuery('#replytopic-form').submit(function(e){ 
      var data = jQuery(this).serializeArray(); 
      jQuery('.topic-loading').show(); 
      e.preventDefault(); 
      var loadUrl = jQuery(this).attr('action'); 
      jQuery.post(
       loadUrl, 
       data, 
       function(responseText){ 
        jQuery('.reply-topic-form-holder').html(responseText); 
        jQuery('.alert-success').each(function(){ 
         jQuery('#replytopic-form textarea').each(function(){ 
          jQuery(this).val(''); 
         }); 
        }); 

        jQuery('.topic-loading').hide(); 
        init_reply_topic_js(); 
       } 
      ); 
     }); 
} 
</script> 
+0

보십시오, 나는 질문 - ckeditor에서와 웹 사이트에서 답을 역류하지 않고 데이터를 얻는 방법, 여기 링크입니다 - https://docs.ckeditor.com/ckeditor4/docs/?mobile=/guide/dev_savedata – TimBrownlaw

+0

그게 내 문제 야. 나는이 문제에 관해 혼란 스럽다. 내게 미친 짓을하기 때문에 나는 구글에서 어떻게 검색 할 지 모르겠다..................... 답변에 감사드립니다. –

+0

나는 당신을 줬다. 봐야 할 링크. 너 봤어? – TimBrownlaw

답변

1

CK 등장하는 코드입니다, 그것은 말하자면위한 단지 '자리'입니다. 따라서 CK의 데이터가 텍스트 영역에 추가되거나 AJAX를 통해 게시 할 때 해당 필드에 대한 데이터를 얻지 못하게해야합니다. 정상적으로 게시 할 때 이것은 autoUpdateElement으로 인해 문제가되지 않습니다.

전에 var data = jQuery(this).serializeArray();을 붙이십시오. CKEDITOR.instances.comment.updateElement();을 입력하십시오. 이렇게하면 CK 에디터의 내부 마크 업이 텍스트 영역에 추가되어 어레이를 직렬화하기 전에 필드를 채울 수 있습니다.

방법에 관한 문서 here. 구글을 요구

jQuery('#replytopic-form').submit(function (e) { 
    CKEDITOR.instances.comment.updateElement(); 
    var data = jQuery(this).serializeArray(); 
    jQuery('.topic-loading').show(); 
    e.preventDefault(); 
    var loadUrl = jQuery(this).attr('action'); 
    jQuery.post(
      loadUrl, 
      data, 
      function (responseText) { 
       jQuery('.reply-topic-form-holder').html(responseText); 
       jQuery('.alert-success').each(function() { 
        jQuery('#replytopic-form textarea').each(function() { 
         jQuery(this).val(''); 
        }); 
       }); 
       jQuery('.topic-loading').hide(); 
       init_reply_topic_js(); 
      } 
    ); 
}); 
+0

대단히 고마워요 .. 지금 일하는 중 .. 멋지다! .. 그런데 ck에 대한 나의 다른 관심사를 확인해 줄 수 있니? 괜찮 으면 ..? https://stackoverflow.com/questions/47763304/ckeditor-not-image-video-link-embed-and-many-others-not-working-in-modal –

관련 문제