2

I tried to do the following:

$this->form_validation->set_rules('username', 'lang:login_username', 'callback_login_check');
$this->form_validation->set_rules('username', 'lang:login_username', 'callback_employee_location_check');

I wouldn't get a valuation error, but this condition was always TRUE:

if($this->form_validation->run() == FALSE)

If I change the above 2 lines to:

$this->form_validation->set_rules('username', 'lang:login_username', 'callback_login_check|callback_employee_location_check');

Then it works as expected. Why can't I use the first form? Does the second one overwrite the first and the login check never gets called?

3
  • What values does your callbacks return? Commented Dec 2, 2013 at 17:45
  • booleans (TRUE, FALSE) Commented Dec 2, 2013 at 17:46
  • 1
    Ok, so one of the callbacks returns false? If that is the case then run() will return false as one of your rules failed. In the second where you OR the callbacks together it looks like it gets TRUE OR FALSE which is going to return true. You can debug that by running line 1, and then running line 2 independently. Commented Dec 2, 2013 at 17:59

1 Answer 1

2

Like you said, when you combine both callbacks inside the set_rules() it works. This is correct. If you enter them in seperatly they overwrite one another. All rules for the form input need to be in the same set_rules() method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.