CodeIgniter - Unable to access an error message corresponding to your field name Password.(pword_check)

后端 未结 6 1809
予麋鹿
予麋鹿 2020-12-09 21:53

I am a new to codeIgniter and I just got stuck in the very beginning. I am using HMVC extention and while validating I am getting the following error:

Unable

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 22:06

    For future searches. There are two 3 things you need to check when this error shows.

    1. Check the name of the callback function if it is the same with the

      $this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check

      public function pword_check($str){                                              
        if ($str == 'test'){
          $this->form_validation->set_message('pword_check', 'The %s field can not be the word "test"');
          return FALSE;
        }
        else{
          return TRUE;
        }                                                                              
      }
      

      *public function pword_check($str){

      *set_message('pword_check', 'The %s field...

    2. In codeigniter 2.X you can do this

      $this->form_validation->run($this) == TRUE

      In 3.x it should be like this

      $this->form_validation->run() == TRUE

      and you need to add this two line of codes on __construct()

      function __construct(){                                     
        parent::__construct();                                                      
        $this->load->library('form_validation');
        $this->form_validation->CI =& $this;                                           
      } 
      
    3. Add this file on your application/libraries/MY_Form_validation.php

    Cheers! See https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/src/f77a3fc9a6fd?at=codeigniter-3.x

    https://www.youtube.com/watch?v=pp4Y_bIhASY&list=PLBEpR3pmwCayNcTCUWlUToK4qIQfFQCCm&index=8

    For reference.

提交回复
热议问题