php - codeigniter form validation doesn't call callback function -
by reason form validation doesn't call callback function set in rules.
it rules sets
if( ! empty($_post)) { ci()->form_validation->set_rules('login', 'username', 'trim|required'); ci()->form_validation->set_rules('email', 'email', 'trim|required|valid_email|callback_check_email'); if (ci()->form_validation->run() == true) { } }
and function
public function check_email($str) { ci()->load->model(array('secure_model', 'admin/members_model')); $o['username'] = ci()->input->post('login'); $o['email'] = ci()->input->post('email'); $m = $this->_model->get_row($o); if ( ! $m) { $this->form_validation->set_message('check_email', lang('unlock_incorrect_login')); return false; } else { return false; } }
i set false
twice see if call callback function doesn't display error message. suppose ci doesn't try call it. wrong?
in check_email()
function, you're using $this->form_validation
instead of ci()->
. i'm not sure why you're using ci()
instead of standard ci way of using $this
that's part in code seems off compared rest.
Comments
Post a Comment