Hi.
I want use form_validation.php file with my rules that I put in application/config.
My problem is that some rules need use functions that are for example in models.
I have this in my form_validation.php file:
PHP Code:
$config = array(
array(
'field' => 'usuario',
'label' => 'Nombre de usuario',
'rules' => 'trim|required|max_length[12]|is_unique[' . db_table('user_table') . '.username]',
'errors' => array(
'is_unique' => 'El nombre de usuario ya está en uso.'
)
),
);
The function "db_table('table_name')" is in the model: examples/examples_model
If I don't use form_validation.php file, I put in my controller:
$this->load->model('examples/examples_model');
Then I can use function "db_table()" without problems when I set set_rules:
$this->form_validation->set_rules('usuario', 'Nombre de usuario', 'trim|required|max_length[12]|is_unique[' . db_table('user_table') . '.username]');
My problem is that if I use form_validation.php file instead set all rules in my controller, I can't use function "db_table()" because it's undefined.
How can I use this external function in my form_validation.php file? Is possible?
Thanks.