Welcome Guest, Not a member yet? Register   Sign In
why can I only pass ONE parameter in callback?
#1

[eluser]chmod[/eluser]
When I use callback__check_username_and_password in rules,only ONE parameter can pass to the custom function. I use a array,but the same to it.

like these:
controller:
-------------------------
function _check_pay_pointnum($check_pay_pointnum){
print_r($check_pay_pointnum);
exit;
$result = $this->pay_model->_check_pay_pointnum($check_pay_pointnum);
if ($result){
return TRUE;
}else{
return FALSE;
}
}

function index(){
if ($this->input->post('submit')){
//check post data
$username = $this->input->post('username');
$reusername = $this->input->post('reusername');
$pointnum = $this->input->post('point');
$cardnum = $this->input->post('cardnum');
$cardpass = $this->input->post('cardpass');
$paycardmd5pass = md5($cardpass);
$pay_type = $this->session->userdata('pay_type');

$check_pay_pointnum = array('pointnum' => $pointnum,'pay_type' =>$pay_type );

$rules['username'] = "trim|required|matches[reusername]|xss_clean|callback__check_username_exist";
$rules['reusername'] = "trim|required|xss_clean";
$rules['point'] = "trim|required|callback__check_pay_pointnum";
$rules['cardnum'] = "trim|required|alpha_numeric|callback__check_cardnum_cardpass";
$rules['cardpass'] = "trim|required|alpha_numeric";

....

}

If I can not pass two parmeters,I will use session data,
and pass one parameter in callback function.

but the thing is not a good idea.Isn't it?

Is there any way to do it?
#2

[eluser]James Gifford[/eluser]
If I need to reference more than one variable in a callback function I just go through the validation class to get them.

eg:
Code:
function _check_login ($username) {
   $this->db->where('username', $username);
   $this->db->where('password', $this->validation->password);
   $query = $this->db->get('users');

   return ($query->num_rows() > 0);
}
#3

[eluser]chmod[/eluser]
thanks to James Gifford




Theme © iAndrew 2016 - Forum software by © MyBB