summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/language/english/form_validation_lang.php52
-rw-r--r--system/libraries/Form_validation.php25
2 files changed, 49 insertions, 28 deletions
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index 8788f5dac..e22b3562c 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -26,32 +26,32 @@
*/
defined('BASEPATH') OR exit('No direct script access allowed');
-$lang['required'] = 'The %s field is required.';
-$lang['isset'] = 'The %s field must have a value.';
-$lang['valid_email'] = 'The %s field must contain a valid email address.';
-$lang['valid_emails'] = 'The %s field must contain all valid email addresses.';
-$lang['valid_url'] = 'The %s field must contain a valid URL.';
-$lang['valid_ip'] = 'The %s field must contain a valid IP.';
-$lang['min_length'] = 'The %s field must be at least %s characters in length.';
-$lang['max_length'] = 'The %s field cannot exceed %s characters in length.';
-$lang['exact_length'] = 'The %s field must be exactly %s characters in length.';
-$lang['alpha'] = 'The %s field may only contain alphabetical characters.';
-$lang['alpha_numeric'] = 'The %s field may only contain alpha-numeric characters.';
-$lang['alpha_dash'] = 'The %s field may only contain alpha-numeric characters, underscores, and dashes.';
-$lang['numeric'] = 'The %s field must contain only numbers.';
-$lang['is_numeric'] = 'The %s field must contain only numeric characters.';
-$lang['integer'] = 'The %s field must contain an integer.';
-$lang['regex_match'] = 'The %s field is not in the correct format.';
-$lang['matches'] = 'The %s field does not match the %s field.';
-$lang['differs'] = 'The %s field must differ from the %s field.';
-$lang['is_unique'] = 'The %s field must contain a unique value.';
-$lang['is_natural'] = 'The %s field must only contain digits.';
-$lang['is_natural_no_zero'] = 'The %s field must only contain digits and must be greater than zero.';
-$lang['decimal'] = 'The %s field must contain a decimal number.';
-$lang['less_than'] = 'The %s field must contain a number less than %s.';
-$lang['less_than_equal_to'] = 'The %s field must contain a number less than or equal to %s.';
-$lang['greater_than'] = 'The %s field must contain a number greater than %s.';
-$lang['greater_than_equal_to'] = 'The %s field must contain a number greater than or equal to %s.';
+$lang['required'] = 'The {field} field is required.';
+$lang['isset'] = 'The {field} field must have a value.';
+$lang['valid_email'] = 'The {field} field must contain a valid email address.';
+$lang['valid_emails'] = 'The {field} field must contain all valid email addresses.';
+$lang['valid_url'] = 'The {field} field must contain a valid URL.';
+$lang['valid_ip'] = 'The {field} field must contain a valid IP.';
+$lang['min_length'] = 'The {field} field must be at least {param} characters in length.';
+$lang['max_length'] = 'The {field} field cannot exceed {param} characters in length.';
+$lang['exact_length'] = 'The {field} field must be exactly {param} characters in length.';
+$lang['alpha'] = 'The {field} field may only contain alphabetical characters.';
+$lang['alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.';
+$lang['alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.';
+$lang['numeric'] = 'The {field} field must contain only numbers.';
+$lang['is_numeric'] = 'The {field} field must contain only numeric characters.';
+$lang['integer'] = 'The {field} field must contain an integer.';
+$lang['regex_match'] = 'The {field} field is not in the correct format.';
+$lang['matches'] = 'The {field} field does not match the {param} field.';
+$lang['differs'] = 'The {field} field must differ from the {param} field.';
+$lang['is_unique'] = 'The {field} field must contain a unique value.';
+$lang['is_natural'] = 'The {field} field must only contain digits.';
+$lang['is_natural_no_zero'] = 'The {field} field must only contain digits and must be greater than zero.';
+$lang['decimal'] = 'The {field} field must contain a decimal number.';
+$lang['less_than'] = 'The {field} field must contain a number less than {param}.';
+$lang['less_than_equal_to'] = 'The {field} field must contain a number less than or equal to {param}.';
+$lang['greater_than'] = 'The {field} field must contain a number greater than {param}.';
+$lang['greater_than_equal_to'] = 'The {field} field must contain a number greater than or equal to {param}.';
/* End of file form_validation_lang.php */
/* Location: ./system/language/english/form_validation_lang.php */ \ No newline at end of file
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index e4eac04ba..ecd5b18df 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -615,7 +615,7 @@ class CI_Form_validation {
}
// Build the error message
- $message = sprintf($line, $this->_translate_fieldname($row['label']));
+ $message = $this->_build_error_msg($line, $this->_translate_fieldname($row['label']));
// Save the error message
$this->_field_data[$row['field']]['error'] = $message;
@@ -767,7 +767,7 @@ class CI_Form_validation {
}
// Build the error message
- $message = sprintf($line, $this->_translate_fieldname($row['label']), $param);
+ $message = $this->_build_error_msg($line, $this->_translate_fieldname($row['label']), $param);
// Save the error message
$this->_field_data[$row['field']]['error'] = $message;
@@ -807,6 +807,27 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
+
+ /**
+ * Build an error message using the field and param.
+ *
+ * @param string The error message line
+ * @param string A field's human name
+ * @param mixed A rule's optional parameter
+ * @return string
+ */
+ protected function _build_error_msg($line, $field = '', $param = '')
+ {
+ // Check for %s in the string for legacy support.
+ if (strpos($line, '%s') !== FALSE)
+ {
+ return sprintf($line, $field, $param);
+ }
+
+ return str_replace(array('{field}', '{param}'), array($field, $param), $line);
+ }
+
+ // --------------------------------------------------------------------
/**
* Get the value from a form