Bootstrap Responsive WYSWIG editor doesnt send input data to php

↘锁芯ラ 提交于 2019-12-07 10:54:18

问题


I'm using this WYSWIG editor. This editor is displayed on a modal of bootstrap.

<form action="<?php echo base_url('dashboard/submit_post'); ?>" method="POST" role="form"  enctype="multipart/form-data">
<div class="form-group">
        <label for="post_title">Post Title</label>
        <input type="text" class="form-control" id="post_title" name="post_title" placeholder="Enter a title">
</div>
<div class="form-group">
        <label for="post_content">Post Content</label>
        <textarea name="post_content" id="post_content" cols="30" rows="3" class="form-control wyswig-editor"></textarea>
</div>

This function submit_post goes like this.

public function submit_post()
{
    $this->process_post();
}

private function process_post()
{
    $clean_post_title = $this->input->post('post_title');
    $clean_post_content = $this->input->post('post_content');

    $data = array(
            'post_title' => $clean_post_title,
            'post_content' => $clean_post_content
            );

    print_r($data);
}

The output of this is that the post title gets displayed but the post content doesnt. It doesnt show any value. I knew this must be because of WYSWIG editor so I disabled the wyswig editor class and then it worked fine. However, one thing I noticed, when I disabled the wyswig editor class and posted "Hello" as the post_content value, it was displayed, then I enabled the wyswig editor and changed the value to "Hello2", the output was still displayed as Hello. Some way the editor created its own textarea and thus the value being displayed is of the original textarea. Please Help.


回答1:


This editor you are using does not automatically insert content to your text_field, you have to do it yourself via javascript like this:

$('#txtEditor').Editor("getText")

Generally this is a bad design and I recommend that you use other bootstrap wysiwyg editors like these,

  • bootstrap-wysiwyg
  • bootstrap-wysihtml5
  • Summernote

I personally use summernote in my projects.



来源:https://stackoverflow.com/questions/31623865/bootstrap-responsive-wyswig-editor-doesnt-send-input-data-to-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!