CI 3 + HMVC form_validation library problem |
I have this couple of rules
PHP Code: $this->form_validation->set_rules('password', 'New Password', 'callback__check_password'); and I receive this message on form submit: 'Unable to access an error message corresponding to your field name New Password.' Even if I use a callback like this PHP Code: public function _check_password($password) { I get same error. (02-01-2015, 11:09 AM)geekita Wrote: I have this couple of rules Where you set the message in your callback, the first var should be the rule name (password). Right now you are setting the message for the rule _check_password, which is the name of the callback not the actual rule. PHP Code: public function _check_password($password) {
Did you try to name it callback_check_password and the method, if you are scared of any interference, make the method "private function check_password()"? Maybe there is a problem with the underscore?
Website: http://avenir.ro
02-01-2015, 06:08 PM
(This post was last modified: 02-01-2015, 06:33 PM by twpmarketing. Edit Reason: additional information )
You have a double underscore in the validation rule function name:
[quote pid='4456' dateline='1422814140'] Code: $this->form_validation->set_rules('password', 'New Password', 'callback__check_password'); [/quote] Try using only one underscore and the function should have no leading underscore in its declaration Your use of an underscore in the method name may be invoking the legacy code for a private function: From the CI 3.0 docs: CodeIgniter-3.0rc/user_guide/general/controllers.html#private-methods Quote:Prefixing method names with an underscore will also prevent them from being called. This is a legacy feature that is left for backwards-compatibility.
CI 3.1 Kubuntu 19.04 Apache 5.x Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing. Clarity is desirable over Brevity every time. (02-01-2015, 06:08 PM)twpmarketing Wrote: You have a double underscore in the validation rule function name: Try using only one underscore and the function should have no leading underscore in its declaration Your use of an underscore in the method name may be invoking the legacy code for a private function: From the CI 3.0 docs: CodeIgniter-3.0rc/user_guide/general/controllers.html#private-methods Quote:Prefixing method names with an underscore will also prevent them from being called. This is a legacy feature that is left for backwards-compatibility. [/quote] Yes, I tried with no underscore but nothing changed. |
Welcome Guest, Not a member yet? Register Sign In |