[eluser]lostsock[/eluser]
Just thought I should point out to PHP 4 users that you cannot load the validation library in the class constructor. You have to load it specifically in the function or via autoload.
The following will fail in PHP 4
Code:
class Test extends Controller {
function Test() {
parent::Controller();
// LOADING THE validation CLASS FROM THE CONTROLLER WILL FAIL IN PHP 4
$this->load->library('validation');
}
function index() {
// Prep Validation
$rules['author'] = "trim|required";
$this->validation->set_rules($rules);
$fields['author'] = 'Author';
$this->validation->set_fields($fields);
if (empty($_POST)) {
$this->validation->author = "Testing";
}
// Run validation
if ($this->validation->run() == FALSE) {
$this->load->view('admin/category');
} else {
die('woohoo!');
}
}
}
To make it work you must either add it to the autoload array or call
$this->load->library('validation'); from within the method itself
Code:
function index() {
$this->load->library('validation');
// ETC...
}
Hope this saves someone else a couple of hours work