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

unable to access an error message corresponding to your field name username xss_clean
registration form validation in codeigniter
codeigniter form validation error array
codeigniter date validation
email validation in codeigniter
codeigniter form validation array fields
callback function in codeigniter form validation example
confirm password validation in codeigniter

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 to access an error message corresponding to your field name Password.(pword_check)

any help would be greatly appreciated

Code:

public function submit()
{


    $this->load->library('form_validation');

    $this->form_validation->set_rules('username', 'Username', 'required|max_length[30]|xss_clean');
    $this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check|xss_clean');

    if ($this->form_validation->run() == FALSE)
    {
        $this->login();
    }
    else
    {
        echo 'Success'; die();
    }
}

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;
    }
}

xss_clean is no longer part of form validation in Codeingitore 3

Just remove xss_clean from your validation roul

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

If you really, really need to apply that rule, you should now also load the Security Helper, which contains xss_clean() as a regular function and therefore can be also used as a validation rule.

go to application/config/autoload.php :

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

Or, before your form validation

$this->load->helper('security');

Unable to access an error message corresponding to your field name., CodeIgniter - Unable to access an error message corresponding to your field name Password.(pword_check) - php. Hello Guys I found the solution for working with call_backs in hmvc codeIgniter. I would like to post the solution for others. Solution: 1. Create MY_Form_validation.php file in libraries folder and paste following code in it.

Hello Guys I found the solution for working with call_backs in hmvc codeIgniter. I would like to post the solution for others.

Solution:

1. Create MY_Form_validation.php file in libraries folder and paste following code in it.

 if (!defined('BASEPATH')) exit('No direct script access allowed');
    class MY_Form_validation extends CI_Form_validation
    {

    function run($module = '', $group = '')
    {
       (is_object($module)) AND $this->CI = &$module;
        return parent::run($group);
    }
}

  1. And change if ($this->form_validation->run() == FALSE) to if ($this->form_validation->run($this) == FALSE) thats all folks..

Form Validation : CodeIgniter User Guide, I am a new to codeIgniter and I just got stuck in the very beginning. error: Unable to access an error message corresponding to your field name Password.(​pword_check) any help would be greatly appreciated Code: public  return get_post_data('username','','Password','username','password'); However, when you design this form you should get the no-requirement from both fields (like do_not_directly) ? Also, don't forget to change the code above to stop using the tips fix, because the user lost a token when I send a user input.

public function pword_check($str)
{

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

// Its working well

https://github.com/bcit-ci/CodeIgniter/issues/3908

Unable to access an error message corresponding to your field , [eluser]Chris Newton[/eluser] So, I'm having a little trouble using MY_validation and I've used it before, so I'm not sure what's going on here. From the codeigniter github : A largely unknown rule about XSS cleaning is that it should only be applied to output, as opposed to input data. We've made that mistake ourselves with our automatic and global XSS cleaning feature (see previous step about XSS above), so now in an effort to discourage that practice, we're also removing 'xss_clean' from the officially supported list of form validation rules .

The reason for this error is you didn't loaded the security helper the following is the way enable security helper with autoload.php in config folder or you can directly load the helper as mentioned last line of this post

And if, despite everything, you really need it, go to application/config/autoload.php :

$autoload['helper'] = array('security'); Or, before your form validation $this->load->helper('security');

Codeigniter+3+Unable+to+access+an+error+message, Unable to access an error message corresponding to your field name Password.(​pword_check). any help would be greatly appreciated. Code: public function  CodeIgniter provides a comprehensive form validation and data prepping class that helps minimize the amount of code you’ll write. Before explaining CodeIgniter’s approach to data validation, let’s describe the ideal scenario: You fill it in and submit it. If you submitted something invalid, or perhaps missed a required item, the form is

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

    <?php                                                                
    class MY_Form_validation extends CI_Form_validation{                                     
        public $CI;                                                                                               
    } 
    

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.

Above error is shown when a field has no value and no required rule: $this->​form_validation->set_rules('address', 'Address', [ 'trim',  | 1 You need to remove word check from your code. Explanation below. I did not want to add some extra MY_Form_validation.php file, so I was trying to fix that in other way:

If you want to create a CodeIgniter login module with sessions than you can go through this tutorial post that will help you to make your simple login and registration form along with database validation.

Hi, I'm currently upgrading my project from version 2.x to 3.x. The login page (which uses form validations) behaves suddently strange by saying that there's a problem with the min/max lenght of my field.

Comments
  • Which version of CI you use???
  • I am using CodeIgniter Version 3.0.1
  • Thanks for you valuable time. I have already tried removing xss_clean thing also I have auto loaded the security helper but error message is still getting displayed for password field.
  • It's a very simple code I don't know what is causing this error.
  • change your message to $this->form_validation->set_message('pword_check', "The %s field can not be the word test"); and check
  • I changed the message to yours but it did't help, again same error (Unable to access an error message ) is getting displayed.
  • This peice of code looks okk. My be problem is with some other part
  • added to libraries in CI 3.0.x, @kev_m
  • Can we have an explanation as to why this works? Thanks a million by the way, saved my life!
  • million thanx, Just a suggestion , you dont need to create the library, instead just pass $this in run function and you are all set $this->form_validation->run($this)
  • Code only answers arent encouraged as they dont provide much information for future readers please provide some explanation to what you have written