Commits

mariano.iglesias  committed 9b5dc57

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@50933807eeeb-6ff5-0310-8944-8be069107fe0

  • Participants
  • Parent commits cec34ae

Comments (0)

Files changed (2)

File cake/libs/model/model.php

 						}
 						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']);

File cake/libs/view/helpers/form.php

 		$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)) {