2013-01-02 3 views
1

저는 codeigniter를 처음 사용하고 사용자 가이드의 튜토리얼을 시도하고 있습니다. 그러나 나는 뉴스 항목을 만드는 세 번째 튜토리얼을 붙였습니다. 여기 내 컨트롤러 섹션에서 다음과 같은 오류를주고있다 :

심각도 :

메시지주의 : 정의되지 않은 속성을 : 뉴스 : $ form_validation

파일 이름 : 컨트롤러/news.php

라인 번호를 44

내가 컨트롤러 부에 사용되는 코드는

public function create() 
{ 
$this->load->helper('form'); 
$this->load->library('form_validation'); 

$data['title'] = 'Create a news item'; 

$this->form_validation->set_rules('title', 'Title', 'required'); 
$this->form_validation->set_rules('text', 'text', 'required'); 

if ($this->form_validation->run() === FALSE) 
{ 
    $this->load->view('templates/header', $data); 
    $this->load->view('news/create'); 
    $this->load->view('templates/footer'); 

} 
else 
{ 
    $this->news_model->set_news(); 
    $this->load->view('news/success'); 
} 
} 
인 0

도와주세요. 사전에

감사합니다.

+0

44 번 줄은 어느 것입니까? –

+0

왜'=='대신'==='를 사용 했습니까? –

+0

이 줄은 다음과 같습니다. $ this-> form_validation-> set_rules ('title', 'Title', 'required'); – user1929236

답변

1

적절하게 로딩 모델을 지정하지 않았습니다. 그래서 당신은 당신이 성공적으로 검증 한 후 사용할 수 있습니다, 모델

$this->news_model->set_news(); 

또는 편집 구성 \의 autoload.php를 호출하고 설정할 수 있습니다 후

$this->load->model('news_model'); 

전에이 포함

news_model::set_news(); 

또는 당신은 생성자에서 다음과 같이 할 수 있습니다 :

class MySomeClas extend CI_Controller 
{ 
    parent::__construct(); 
    $this->load->model('news_model'); 
} 

및 모델 바로 호출

0

config/autoload.php에서이 form_validation 라이브러리를 추가하면 100 % 작동합니다.

$autoload['libraries'] = array('form_validation'); 
관련 문제