[eluser]Santiag0[/eluser]
Hello there!
I have this form to edit the users
Code:
<input type="text" name="username[]" value="Foo" >
<input type="hidden" name="user_id[]" value="20" >
<input type="password" name="password[]" value="Foo" >
<input type="text" name="username[]" value="Bar" >
<input type="hidden" name="user_id[]" value="21" >
<input type="password" name="password[]" value="Bar" >
I want to check if the new name of the user is already taken by other user.
I think that i can do this using a callback, like
Code:
$this->form_validation->set_rules('username[]', 'user name', 'trim|required|callback__user_exists[user_id[]]');
function _user_exists($username, $user_id)
{
if ($this->admin_users_model->user_exists($username, $user_id)
{
$this->form_validation->set_message('_user_exists', 'The name '. $username .' is already taken.');
return FALSE;
}
else
return TRUE;
}
But looks that i can't pass the value of other input as argument of a callback.
Please, how can I make a callback with 2 input values?
I tried with $this->input('username') but returns an array, and I need to run the callback with the corresponding user_id.
I need this to do a query like
Code:
$this->db->get_where('users', array("username"=>$username, "user_id !="=>$user_id));
Thanks in advance for your help!
Sorry for my poor english.