0

I have this code below. My problem is it only triggers the callback. The required and valid_email rules are not called. I'm expecting to execute the rules in order. But when I remove the callback it runs normal. TIA.

$this->form_validation->set_rules('search_word', 'Email address', 'trim|required|valid_email|callback_has_valid_credentials');

$this->form_validation->set_message('has_valid_credentials', '{field} is not registered in the system.');

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

    $this->load->view('login/reset');
    return;
    }
3
  • Did you define a function that named has_valid_credentials ? Commented Nov 28, 2016 at 11:49
  • Please, try this ;) Commented Nov 28, 2016 at 12:25
  • @ErolKESKİN yes, i have function named has_valid_credentials. I tried with the prefix callback_has_valid_credentials and it searched thru the db. I also tried without the callback_ prefix and the required and valid_email are both working but the callback is not. Is it a bug? Commented Nov 29, 2016 at 5:20

1 Answer 1

1

You don't have a function named has_valid_credentials defined.

public function has_valid_credentials($str) {
    /** Write validation code here **/
}

For your reference, check out the documentation.

https://www.codeigniter.com/userguide3/libraries/form_validation.html#callbacks-your-own-validation-methods

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

1 Comment

Sorry. I did not include the has_valid_credentials function code but I have. I'm just pointing out the issue that whenever I include the callback, the two other rules are not triggered, only the callback.

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.