Postingan lainnya
Undefined property: U::$form_validation
Mohon bantuannya mastah.. ini kalimat lengkap erornya..
//////////////////////////////////
A PHP Error was encountered
Severity: Notice
Message: Undefined property: U::$form_validation
Filename: controllers/U.php
Line Number: 28
Backtrace:
File: D:\xampp\htdocs\karyaid\application\controllers\U.php
Line: 28
Function: _error_handler
File: D:\xampp\htdocs\karyaid\index.php
Line: 315
Function: require_once
////////////////////////////////////
An uncaught Exception was encountered
Type: Error
Message: Call to a member function set_rules() on null
Filename: D:\xampp\htdocs\karyaid\application\controllers\U.php
Line Number: 28
Backtrace:
File: D:\xampp\htdocs\karyaid\index.php
Line: 315
Function: require_once
Nah masalahnya kan di kontroller U, ini isi filenya.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class U extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('artikel_model');
}
///halaman dasbor
public function index()
{
$artikel = $this->artikel_model->get_artikel();
$data = array(
'artikel' => $artikel,
'isi' => 'u/index'
);
$this->load->view('layout/wrapper', $data);
}
public function post(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('judul_artikel', 'Judul', 'trim|required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('isi_artikel', 'Artikel', 'trim|required|min_length[5]');
$this->form_validation->set_rules('status_artikel', 'Status', 'trim|required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('jenis_artikel', 'Jenis', 'trim|required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('keywords', 'Keywords', 'trim|required|min_length[5]');
if($this->form_validation->run() === FALSE){
$data = array(
'isi' => 'u/post'
);
$this->load->view('layout/wrapper', $data);
}else{
$this->artikel_model->set_artikel();
redirect('u/');
}
}
public function postingan(){
$data = array(
'isi' => 'u/postingan'
);
$this->load->view('layout/wrapper', $data);
}
}
/* End of file U.php */
/* Location: ./application/controllers/U.php */
Bantuin ngatasin masalah ini mastah, saya bener-bener gk nemu solusinya. Ini saya juga belajar perograman otodidak, jadi masih banyak kebingungan dan bug. Jd mohon bantuannya buat belajar
4 Jawaban:
boleh liat model nya gan? gw ane pernah nemu masalah kaya gitu karena di model ane extends ci_controller dan harusnya ci_model
heeemmm
ke sini coba config/autoload.php ubah jadi gini
<pre> $autoload['libraries'] = array('form_validation'); </pre>
<div>ini masalahnya cuma satu... autoload set aja form validationnya.. lalu periksa model apakah udah extend CI_Model apa belum.. biasanya orang kalau copas suka lupa ke CI_Controler</div>