summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Phaninder Reddy Jonnala <sai.jonnala@gopassport.com>2016-02-08 15:32:24 +0100
committerSai Phaninder Reddy Jonnala <sai.jonnala@gopassport.com>2016-02-08 15:32:24 +0100
commitdd149da93a2064937e490977343d152207b73815 (patch)
tree908b5d6b60109d83704c3dad73876208452ebcc0
parent0f13e09ebb153315539e1ff7f77698f2709996b5 (diff)
code styling changes as suggested by @narfbg
-rw-r--r--system/libraries/Form_validation.php36
1 files changed, 15 insertions, 21 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index c37a73418..da5ab4e04 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -637,7 +637,7 @@ class CI_Form_validation {
// Set the message type
$type = in_array('required', $rules) ? 'required' : 'isset';
- $line = $this->_get_raw_error_message($type, $row);
+ $line = $this->_get_error_message($type, $row["field"]);
// Build the error message
$message = $this->_build_error_msg($line, $this->_translate_fieldname($row['label']));
@@ -808,7 +808,7 @@ class CI_Form_validation {
}
else
{
- $line = $this->_get_raw_error_message($rule, $row);
+ $line = $this->_get_error_message($rule, $row["field"]);
}
// Is the parameter we are inserting into the error message the name
@@ -839,40 +839,34 @@ class CI_Form_validation {
/**
* Get the error message for the rule
*
- * @param string the rule name.
- * @param array
+ * @param string $rule The rule name
+ * @param string $field
+ *
* @return string
*/
- private function _get_raw_error_message($rule_name, $row)
+ protected function _get_error_message($rule, $field)
{
- $error_message = '';
// check if a custom message is defined through validation config row.
- if (isset($this->_field_data[$row['field']]['errors'][$rule_name]))
+ if (isset($this->_field_data[$field]['errors'][$rule]))
{
- $error_message = $this->_field_data[$row['field']]['errors'][$rule_name];
+ return $this->_field_data[$field]['errors'][$rule];
}
// check if a custom message has been set using the set_message() function
- elseif (isset($this->_error_messages[$rule_name]))
+ elseif (isset($this->_error_messages[$rule]))
{
- $error_message = $this->_error_messages[$rule_name];
+ return $this->_error_messages[$rule];
}
- // check if we have an error message in lang file
- elseif (FALSE !== ($line_tmp = $this->CI->lang->line('form_validation_'.$rule_name)))
+ elseif (FALSE !== ($tmp = $this->CI->lang->line('form_validation_' . $rule)))
{
- $error_message = $line_tmp;
+ return $tmp;
}
// DEPRECATED support for non-prefixed keys, lang file again
- elseif (FALSE !== ($line_tmp = $this->CI->lang->line($rule_name, FALSE)))
- {
- $error_message = $line_tmp;
- }
- // error message not found
- else
+ elseif (FALSE !== ($tmp = $this->CI->lang->line($rule, FALSE)))
{
- $error_message = $this->CI->lang->line('form_validation_error_message_not_set').'('.$rule_name.')';
+ return $tmp;
}
- return $error_message;
+ return $this->CI->lang->line('form_validation_error_message_not_set'). '(' . $rule . ')';
}
// --------------------------------------------------------------------