Welcome Guest, Not a member yet? Register   Sign In
Anonymous function Validation
#1

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!
Reply


Messages In This Thread
Anonymous function Validation - by burgoyn1 - 01-29-2017, 10:00 PM
RE: Anonymous function Validation - by PaulD - 01-30-2017, 11:40 AM
RE: Anonymous function Validation - by burgoyn1 - 01-30-2017, 01:45 PM
RE: Anonymous function Validation - by PaulD - 01-30-2017, 02:01 PM
RE: Anonymous function Validation - by burgoyn1 - 01-31-2017, 04:37 AM
RE: Anonymous function Validation - by shernandez - 06-12-2017, 06:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB