CodeIgniter错误问题:: $ form_validation

时间:2015-01-02 01:46:22

标签: php codeigniter validation

您好我在codeigniter中收到错误,

  

消息:未定义的属性:Questions :: $ form_validation

     

文件名:controllers / questions.php

     

行号:43

我的Questions.php控制器,它不是默认控制器BTW。

class Questions extends CI_Controller{
  public function user_logged_in(){
    $this->load->library('../controllers/main');
    $obj = new $this->main();
    $status = $obj->logged_in();
    if($status){
        return true;
    }else{
     return false;
     }
   }

   public function validate_question(){
      if($this->user_logged_in()== true){
      $this->load->library("form_validation");
      $this->form_validation->set_rules("input_title","Title","required");
      $this->form_validation->set_rules("message","Description","required");
      $this->form_validation->set_rules("vidya","Description","required");
      if($this->form_validation->run()){
          echo "Form has been Submitted";
      }else{
          $this->load->view('question_posts/post_questions');
      }
   }else{
      redirect('main/index');
   }
 }
}//end of class Questions

我甚至通过

在我的config / autoload.php中自动加载
$autoload['helper'] = array("form");

现在我不知道为什么这个错误仍然存​​在。或者是因为我已经在user_logged_in()方法中加载了一个库。除此之外,我对这个错误发生的原因如此无奈。

0 个答案:

没有答案