Custom validation method - Issue with error message. |
Code: class Form extends CI_Controller { The above validation fails with this error message Code: "Unable to access an error message corresponding to your field name" I tried to search on SO and this one seem to be the exact issue I am having - http://stackoverflow.com/questions/32665...field-name The OP was able to resolve this issue (see his own answer) Code: 1. Create MY_Form_validation.php file in libraries folder and paste following code in it. But still didn't resolve the issue for me. What do I do?
I guess you must load the form validation library inside that callback method (username_check...) too. You are calling form_validation but you didn't load the library.
Website: http://avenir.ro
Hello - Actually I have loaded the form validation library in the constructor. The above code was just copied & pasted from the CI documentation as my code was very identical except as mentioned below. http://www.codeigniter.com/userguide3/li...on-methods
This rule in the example above works fine so I was wrong to say it doesn't work. I had used an additional rule "email" which was a typo as it should have been "valid_email" and that was causing this error for me. This is what I had in my rules list. Code: $this->form_validation->set_rules('username', 'Username', 'email|callback_username_check'); So basically, everything works well. My typo created the problem for me. Please close my thread. Thank you. |
Welcome Guest, Not a member yet? Register Sign In |