Welcome Guest, Not a member yet? Register   Sign In
Form validation error messages from language file?
#1
Question 

Hi guys,

I'm trying to pull error messages from a lang file for my form validation. I've got the validation in a config file which looks like this:

PHP Code:
$config = array(
    
'auth_c/login' => array(
        array(
            
'field' => 'identity',
            
'label' => 'lang:identity',
            
'rules' => array(
                
'required',
                array(
                    
'is_valid_identity_callable',
                    function(
$str) {
                        
$ci =& get_instance();
                        return 
$ci->auth->is_valid_identity($str);
                    }
                )
            ),
            
'errors' => array(
                
'required' => 'lang:error_missing_param',
                
'is_valid_identity_callable' => 'lang:error_auth_identity_used'
            
)
        ),
        array(
            
'field' => 'password',
            
'label' => 'lang:password',
            
'rules' => array(
                
'required'
            
),
            
'errors' => array(
                
'required' => 'lang:error_missing_param',
            )
        )
    )
); 

From the docs, I saw I could do "lang:identity" for the field label - and that works great - but the same thing doesn't work for error messages.

I've tried a few different ways but can't seem to get it to load from the lang file with a setup like this in a form_validation.php config file.

This seems like a common scenario, so I'm sure there's a way to do it, but I just can't seem to find it.

Any help would be greatly appreciated.


Thanks,
Jay.
Reply


Messages In This Thread
Form validation error messages from language file? - by JayAdra - 04-10-2015, 12:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB