[eluser]andygo[/eluser]
I am trying to create a library class in my application.
I am experimenting with the form validation class example from the docs.
I seperated soem of the code and put it in a library file.
It works except for the call back function. I havent changed anything so I was wondering if there's something I'm missing in having it in a library class.....
Here's the library class code:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
*
*
*/
class Form_data_lib
{
public function __construct()
{
$this->ci =& get_instance();
$this->ci->load->library('form_validation');
}//end construct
//janitor
public function janitor()
{
$this->ci->form_validation->set_rules('username', 'Username', 'callback_username_check');
$this->ci->form_validation->set_rules('password', 'Password', 'required');
$this->ci->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->ci->form_validation->set_rules('email', 'Email', 'required');
if ($this->ci->form_validation->run() == FALSE)
{
return '0';
}
else
{
return '1';
}
}
public function username_check($str)
{
if ($str == 'test')
{
$this->ci->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}
}
}//end class
/* End of file Form_data_lib.php */
/* Location: ./application/libraries/Form_Data_lib.php */
Any help appreciated.
BTW: It works fine when set up as per the docs.