Fixing support for error messages when multiple validation rules are used with numeric indexes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5093 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-05-14 10:37:23 +00:00
parent cec34ae6df
commit 9b5dc57881
2 changed files with 8 additions and 1 deletions

View file

@ -1745,7 +1745,11 @@ class Model extends Overloadable {
}
if (!$valid) {
if (!isset($validator['message'])) {
$validator['message'] = ife(is_string($index) || (is_numeric($index) && count($ruleSet) > 1), $index, $message);
if (is_string($index)) {
$validator['message'] = $index;
} else {
$validator['message'] = ife(is_numeric($index) && count($ruleSet) > 1, ($index + 1), $message);
}
}
$this->invalidate($fieldName, $validator['message']);

View file

@ -310,6 +310,9 @@ class FormHelper extends AppHelper {
$options = am(array('wrap' => true, 'class' => 'error-message', 'escape' => true), $options);
if ($error = $this->tagIsInvalid()) {
if (is_array($text) && is_numeric($error) && $error > 0) {
$error--;
}
if (is_array($text) && isset($text[$error])) {
$text = $text[$error];
} else if (is_array($text)) {