CodeIgniter Forums
Form Validation Type Match Not Translating - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Validation Type Match Not Translating (/showthread.php?tid=36763)



Form Validation Type Match Not Translating - El Forum - 12-14-2010

[eluser]Unknown[/eluser]
I am working on a multilingual site using several language files and I noticed that on the form validation it didn't translate the referencing form field in the 'match[]' validation type.

For example it would output something like this:

"The Confirm Password field does not match the lang:label_password field."
instead of
"The Confirm Password field does not match the Password field."

I fixed it by changing the following in the Form_validation library:
Code:
// Is the parameter we are inserting into the error message the name
// of another field?  If so we need to grab its "field label"

if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label']))
{
  $param = $this->_field_data[$param]['label'];
}
                
// Build the error message
/* Old Code */
//$message = sprintf($line, $this->_translate_fieldname($row['label']), $param);

/* New Code */
$message = sprintf($line, $this->_translate_fieldname($row['label']), $this->_translate_fieldname($param));