Skip to content

Commit 69c5644

Browse files
committed
[ci skip] Fix error notices in FV when trying to lookup error msgs for closures
1 parent 9e9d86b commit 69c5644

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

system/libraries/Form_validation.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -791,23 +791,27 @@ protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
791791
// Did the rule test negatively? If so, grab the error.
792792
if ($result === FALSE)
793793
{
794-
// Check if a custom message is defined
795-
if (isset($this->_field_data[$row['field']]['errors'][$rule]))
796-
{
797-
$line = $this->_field_data[$row['field']]['errors'][$rule];
798-
}
799-
elseif ( ! isset($this->_error_messages[$rule]))
794+
// Callable rules don't have named error messages
795+
if ( ! is_callable($rule))
800796
{
801-
if (FALSE === ($line = $this->CI->lang->line('form_validation_'.$rule))
802-
// DEPRECATED support for non-prefixed keys
803-
&& FALSE === ($line = $this->CI->lang->line($rule, FALSE)))
797+
// Check if a custom message is defined
798+
if (isset($this->_field_data[$row['field']]['errors'][$rule]))
804799
{
805-
$line = 'Unable to access an error message corresponding to your field name.';
800+
$line = $this->_field_data[$row['field']]['errors'][$rule];
801+
}
802+
elseif ( ! isset($this->_error_messages[$rule]))
803+
{
804+
if (FALSE === ($line = $this->CI->lang->line('form_validation_'.$rule))
805+
// DEPRECATED support for non-prefixed keys
806+
&& FALSE === ($line = $this->CI->lang->line($rule, FALSE)))
807+
{
808+
$line = 'Unable to access an error message corresponding to your field name.';
809+
}
810+
}
811+
else
812+
{
813+
$line = $this->_error_messages[$rule];
806814
}
807-
}
808-
else
809-
{
810-
$line = $this->_error_messages[$rule];
811815
}
812816

813817
// Is the parameter we are inserting into the error message the name

0 commit comments

Comments
 (0)