I am trying to use a function from another class as a validation function. The validation is able to call the function just fine and run it, but it will not return the error message for me to display on the screen. I am not sure what I am missing. I am running it in php 7.
Then in the other class the following function:
I am following the documentation here, which is apparently not working : https://www.codeigniter.com/user_guide/l...-as-a-rule
The message I get back is: Unable to access an error message corresponding to your field name Email Address.(Anonymous function)
Currently I am going through the framework to try to figure out why I am getting this but if someone could explain why it doesn't work like the documentation says, that would be awesome!
PHP Code:
$this->load->library( 'form_validation' );
$this->load->helper( 'form' );
$this->form_validation->set_rules( 'email', 'Email Address', [ 'trim', 'required', 'valid_email', [ 'permission_exists', $this->Usermodel->permission_exists( $this->input->post( 'email' ), $user['id'] ) ] ] );
Then in the other class the following function:
PHP Code:
function permission_exists( $email, $id )
{
$this->load->library( 'form_validation' );
$query = $this->db->get(); //took out the actual query but the query does work and returns
if ( $query->num_rows() == 0 )
{
return TRUE;
}
else
{
$this->form_validation->set_message( 'permission_exists', 'This user already has access.' );
return FALSE;
}
}
I am following the documentation here, which is apparently not working : https://www.codeigniter.com/user_guide/l...-as-a-rule
The message I get back is: Unable to access an error message corresponding to your field name Email Address.(Anonymous function)
Currently I am going through the framework to try to figure out why I am getting this but if someone could explain why it doesn't work like the documentation says, that would be awesome!