Unable to access an error message corresponding to your field name

前端 未结 5 734
情书的邮戳
情书的邮戳 2020-12-29 23:37

I have a callback function that check_captcha which sees if $row is ==0 or == 1 (this information is queried from sql).

The p

相关标签:
5条回答
  • 2020-12-29 23:51

    That helped me

    go to application/config/autoload.php and add "Security" helper class there.

    $autoload['helper'] = array('security');
    

    Or add this before your form validation

    $this->load->helper('security');
    
    0 讨论(0)
  • 2020-12-29 23:51

    You can set error message in set_rules :

    $this->form_validation->set_rules('captcha', 'Captcha', 'callback_check_captcha',

    array('check_captcha' => 'text dont match captcha'));

    0 讨论(0)
  • 2020-12-30 00:00

    Actually the best way, instead of write the error message directly on controller, would be add this entry "check_captcha" on languages.

    In my case, the message for validation rule (form validation) "less_than" was not present.

    I changed the file /system/language/??/form_validation_lang.php. I've added the missing entry.

    0 讨论(0)
  • 2020-12-30 00:04
    $this->form_validation->set_message('check_captcha', 'text dont match captcha');
    

    The message name corresponds to the function, not the field. So setting it to "check_captcha" will fix your bug. The error message will use the correct field name.

    0 讨论(0)
  • 2020-12-30 00:07

    add a entry to your language file with named of the part inside the (yourfieldname) of the errormessage - thats solved the problem

    0 讨论(0)
提交回复
热议问题