How to translate field name in error message ?

edited September 2012 in Modules
for example:
[code]
$lang['error_not_number'] = '%1s****';
[code]

I have a field named ref, must be a number.
I translate it in the exampl_lang.php

[code]
$lang['form_label_ref'] = 'Ref code';
[code]

the invalid error message will display as 【Value needs to be a number for 'ref'】.
how can I get the error msg like this 【Value needs to be a number for 'Ref code'】 ?

can I custom that msg just like required error msg:

[code]
public $required = array('ref' => 'Ref code shouldn't leave blank!');
[code]

need help...

Comments

  • edited 2:02PM
    There is a lang key of "error_not_number" that you would need to change in the fuel/modules/fuel/language/english/fuel_lang.php file.

    The "auto_validate_field" method in MY_Model is where that validation is being set and you'll see that there are other language references like the following:
    error_value_exceeds_length
    error_invalid_date
    error_invalid_year
    error_invalid_generic
  • edited September 2012
    got it!

    "auto_validate_field" method in MY_Model :

    there is a sentence
    【case 'number':
    $this->validator->add_rule($field, 'is_numeric', lang('error_not_number', $field_name), $value);】

    change to:
    【case 'number':
    $this->validator->add_rule($field, 'is_numeric', lang('error_not_number', lang($field)), $value);】

    in your application/language/english/****_lang.php, you will need a translate like 【$lang['ref'] = 'Ref-Code';】

    Love FUELcms,
    Good job DAYLIGHT!
Sign In or Register to comment.