domino 发表于 2016-3-24 20:29:58

验证 form 无法返回错误

用ci 3.x 在练习写一个blog遇到一些问题http://localhost/blog/post/6 这是其中一篇文章
文章下方有个回应文章的功能,提交的路由为
http://localhost/blog/comments/add_comment/6

问题:
如果form_validation= FALSE , redirect 后, 為什麼无法显示 form_error 信息,
请问是哪里出问题了呢?


class Comments extends CI_Controller {
       
      public function __construct()
      {
                parent::__construct();

      }
      public function add_comment($post_id){
                        $name = $this->input->post('name',true);
                           $email = $this->input->post('email',true);
                           $comment = $this->input->post('comment',true);

                           $this->form_validation->set_rules("name", "name", "trim|required");
                           $this->form_validation->set_rules("email", "email", "trim|required");
                           $this->form_validation->set_rules("comment", "comment", "trim|required");
                       
                                if ($this->form_validation->run() == FALSE)
                                {
                                        redirect('post/$post_id);
                                }
                                else
                                {
       
                                       
                                }


                }       



yuzhigang5460 发表于 2016-3-25 09:58:15

redirect('post/$post_id);
这里跳转走了,错误不会被携带,
另外,视图中需要输出错误。
页: [1]
查看完整版本: 验证 form 无法返回错误