Form validation callbacks not working |
Hello,
After upgrade from 2.2.6 to 3.1.9. I noticed my callback function for form validation not working. PHP Code: function update_password() PHP Code: public function currentpass_check($str) I am getting this error. My callback function ( currentpass_check) returns TRUE.
Instead of
PHP Code: $this->form_validation->set_message('currentpass_check', 'Current password Didn\'t match'); PHP Code: $this->form_validation->set_message('current_password', 'Current password Didn\'t match'); untested...
@Codehoster,
...or simply try using the double quotes. PHP Code: $this->form_validation->set_message('current_password', "Current password Didn't match");
(01-02-2019, 10:34 AM)Codinglander Wrote: Instead of Same error! https://www.codeigniter.com/userguide3/l...ation.html In documentation your recommendation is not valid.
Try changing it to this:
PHP Code: $this->form_validation->set_message('current_password', 'Current password do not match'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Are you absolutely sure that it returns TRUE? It dosen't need to access a message in case it's TRUE, only on FALSE.
Are these function placed in the same .php file or are you extending it?
The set_message method allows you to set your own error messages on the fly. But one thing you should notice is that the key name has to match the function name that it corresponds to.
If you need to modify your custom rule, which is _check_valid_username, you can do so by perform set_message within this function: function _check_valid_username($str) { // Your validation code // ... // Put this in condition where you want to return FALSE $this->form_validation->set_message('_check_valid_username', 'Error Message'); // } If you want to change the default error message for a specific rule, you can do so by invoking set_message with the first parameter as the rule name and the second parameter as your custom error. E.g., if you want to change the required error : $this->form_validation->set_message('required', 'Oops this %s is required'); If by any chance you need to change the language instead of the error statement itself, create your own form_validation_lang.php and put it into the proper language folder inside your system language directory.
I will not SEO spam!
|
Welcome Guest, Not a member yet? Register Sign In |