Welcome Guest, Not a member yet? Register   Sign In
CI 3 + HMVC form_validation library problem
#2

(02-01-2015, 11:09 AM)geekita Wrote: I have this couple of rules



PHP Code:
$this->form_validation->set_rules('password''New Password''callback__check_password');
$this->form_validation->set_rules('confirm_password''Confirm new password''matches[password]');

...

public function 
_check_password($password) {
    $result = empty($password) || (strlen($password) >= 10);

    if ($result === FALSE) {
        $this->form_validation->set_message('_check_password''MESSAGE ERROR');
    }

    return $result;


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) {
 
   $this->form_validation->set_message('_check_password''MESSAGE ERROR');

 
   return TRUE // or FALSE;


I get same error.

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) {
    
$result = empty($password) || (strlen($password) >= 10);

    if (
$result === FALSE) {
        
$this->form_validation->set_message('password''MESSAGE ERROR');
    }

    return 
$result;

Reply


Messages In This Thread
RE: CI 3 form_validation library problem - by egall8 - 02-01-2015, 11:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB