Probably there is something I am missing out. I looked around the web and SO for an answer for nothing fixed it for me. Here's my problem: I am loading form_validation
library in the __construct
method still PHP complains that validation_errors
method is undefined. Also form
helper is autoloaded.
...
...
function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->library('form_validation');
$this->load->helper('url');
....
....
function login()
{
$this->data['title'] = "Login";
.....
.....
//the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
Error is thrown on the last line above. (This code is part of ion_auth module http://benedmunds.com/ion_auth/)
You may try this:
$this->data['message'] = ($this->form_validation->run() == False) ? validation_errors() : $this->session->flashdata('message');
Also make sure helper (form_helper.php)
is loaded before you call the validation_errors()
helper function because this function is available in this helper file. To load the helper file you may use:
$this->load->helper('form');
You should call run() method of form_validation class. Also you should define form variables.
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
$this->data['message'] = $this->session->flashdata('message');