Bootstrap 响应式 WYSIWYG 编辑器不会将输入数据发送到 php

Bootstrap Responsive WYSWIG editor doesnt send input data to php

我正在使用 this 所见即所得编辑器。此编辑器显示在 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>

这个函数submit_post是这样的。

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);
}

此输出是显示 post 标题但 post 内容不显示。它没有显示任何价值。我知道这一定是因为 WYSWIG 编辑器所以我禁用了 wyswig 编辑器 class 然后它工作正常。但是,我注意到一件事,当我禁用 wyswig 编辑器 class 和 posted "Hello" 作为 post_content 值时,它显示,然后我启用所见即所得编辑器并将值更改为"Hello2",输出仍然显示为Hello。编辑器以某种方式创建了自己的文本区域,因此显示的值是原始文本区域的值。请帮助。

您使用的这个编辑器不会自动将内容插入到您的 text_field,您必须像这样通过 javascript 自己插入内容:

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

通常这是一个糟糕的设计,我建议您使用其他 bootstrap 所见即所得的编辑器,例如

我个人在我的项目中使用 summernote