Hi, im trying to check if email is already in use when editing. If email is not changed from edit form all OK, but if email is changed have to check if new email is not already in use. Im trying to set a callback on email validation rule:
$crud->set_rules('email', 'email', 'required|valid_email|callback_email_check');
Then I've (I have to modify, got from another post)
public function email_check($email) { $primary_key = $this->uri->segment(4); dump($email); dump($primary_key); $this->form_validation->set_message('email_check', 'The email - ' . $email . ' already is assigned to some other user'); $rows = $this->cModel->getAllFor('retailer_acct', 'email', $email); if(!empty($primary_key) && is_numeric($primary_key)) { if(count($rows)>0) { if($rows[0]['id'] != $primary_key) { $this->form_validation->set_message('email_check', 'The email - ' . $email . ' already is assigned to some other user'); return false; } } return true; } else { if(count($rows)>0) { $this->form_validation->set_message('email_check', 'The email - ' . $email . ' already is assigned to some other user'); return false; } else { return true; } } }
But on firebug I've no dumps and returning always: "FIXME('form_validation_email_check')" and "{"success":false,"error_message":"<p>FIXME('form_validation_email_check')<\/p>\n","error_fields":{"email":"FIXME('form_validation_email_check')"}} JSON.
Any help? I think is not calling callback function on validation email... Thanks!
EDIT: email field is in another table (i don't know if this has any relation with the problem)