如何验证CI中ckeditor的数据

时间:2017-10-10 12:32:12

标签: php codeigniter

我需要验证ckeditor的数据。有没有办法在CodeIgniter中验证它?我试过这样的。

在视图中:

<div class="col-sm-12 col-md-10"> 
        <textarea class="ckeditor" name="desc" id="editor" required><?php echo set_value('desc', ''); ?></textarea>
        <span class="error"><?php echo form_error('desc'); ?></span>
</div>

在控制器中:

$this->form_validation->set_rules('desc', 'Desc', 'required');
if ($this->form_validation->run() == FALSE) {
    $this->add_Coachs();
} else {

    $rs = $this->functional->insertBlog();

    if ($rs == true) {
        $this->session->set_flashdata('blog', 'Your Blog Submitted Successfully.Thank You!');
        redirect('Wall');
    } else {
        $this->session->set_flashdata('blog', 'Blog Not Submitted');
        redirect('Wall');
    }
}

但是在这里执行错误的条件。谁能告诉我哪里出错了?有什么方法可以解决这个问题吗?

已编辑:

模特:

public function insertBlog() {

    $full_name = $this->session->userdata('first_name') . " " . $this->session->userdata('last_name');
    $email = $this->session->userdata('email');
    $data = array(
        'user_id' => $this->input->post('user_id'),
        'full_name' => $full_name,
        'email' => $email,
        'desc' => $this->input->post('desc'),
        'create_date' => date('Y-m-d h:i:s', now()),
        'modify_date' => date('Y:m:d h:i:s'),
        'start_date' => date('Y:m:d h:i:s'),
        'end_date' => date('Y:m:d h:i:s'),
        'status' => "Deactive",
        'userby' => $this->input->post('user_id')
    );
    $rs = $this->db->insert('ult_latest_blog', $data);
    return $rs;
}

0 个答案:

没有答案