Based on the documentation, %s will be replaced by field name when setting error messages.
If you include %s in your error string, it will be replaced with the
“human” name you used for your field when you set your rules.
Is there a way to have multiple %s in the string and define them differently?
This is the line in the form validation library that creates the error message:
$line: The error message template, for example “The % field is invalid”$this->_translate_fieldname($row['label']): The field’s label$param: The parameter passed the the validation function, if any,max_length[5]would pass “5”So that’s the extent of what the form validation class does for you. If you need more flexibility you’ll have to prepare the error message yourself <– might be useful beforehand with the extra variables already populated.
It might be interesting to extend the form validation class via
core/MY_form_validation.phpand work this functionality in. Unfortunately this line is contained in the main function_executewhich is very big and messy, and from looking at it now, you’d need to overload some other functions as well. I started to write an example but it actually looks like a chore. You might be better off using:More on setting error messages: http://ellislab.com/codeigniter/user_guide/libraries/form_validation.html#settingerrors