mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
cec34ae6df
commit
9b5dc57881
2 changed files with 8 additions and 1 deletions
|
@ -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']);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue