Bootstrap Responsive WYSWIG editor doesnt send inp

2019-05-05 03:39发布

问题:

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.