Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Anonymous function Validation

$
0
0
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.


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() == )
 
  {
 
     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!

Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>