mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-31 02:28:35 +08:00
Bug #15826: Fixed JavaScript compareValidator in yii.validation.js for attributes not in rules (mgrechanik)
This commit is contained in:
committed by
Alexander Makarov
parent
71424a42fa
commit
1ad85c640b
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
|||||||
2.0.16 under development
|
2.0.16 under development
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
- Bug #15826: Fixed JavaScript compareValidator in `yii.validation.js` for attributes not in rules (mgrechanik)
|
||||||
- Enh #16365: Added $filterOnFocusOut option for GridView (s1lver)
|
- Enh #16365: Added $filterOnFocusOut option for GridView (s1lver)
|
||||||
- Enh #14289: Added `yii\db\Command::executeResetSequence()` to work with Oracle (CedricYii)
|
- Enh #14289: Added `yii\db\Command::executeResetSequence()` to work with Oracle (CedricYii)
|
||||||
- Enh #9133: Added `yii\behaviors\OptimisticLockBehavior` (tunecino)
|
- Enh #9133: Added `yii\behaviors\OptimisticLockBehavior` (tunecino)
|
||||||
|
|||||||
@ -274,12 +274,11 @@ yii.validation = (function ($) {
|
|||||||
if (options.compareAttribute === undefined) {
|
if (options.compareAttribute === undefined) {
|
||||||
compareValue = options.compareValue;
|
compareValue = options.compareValue;
|
||||||
} else {
|
} else {
|
||||||
var attributes = $form.data('yiiActiveForm').attributes
|
var $target = $('#' + options.compareAttribute);
|
||||||
for (var i = attributes.length - 1; i >= 0; i--) {
|
if (!$target.length) {
|
||||||
if (attributes[i].id === options.compareAttribute) {
|
$target = $form.find('[name="' + options.compareAttributeName + '"]');
|
||||||
compareValue = $(attributes[i].input).val();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
compareValue = $target.val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.type === 'number') {
|
if (options.type === 'number') {
|
||||||
|
|||||||
@ -248,6 +248,7 @@ class CompareValidator extends Validator
|
|||||||
$compareAttribute = $this->compareAttribute === null ? $attribute . '_repeat' : $this->compareAttribute;
|
$compareAttribute = $this->compareAttribute === null ? $attribute . '_repeat' : $this->compareAttribute;
|
||||||
$compareValue = $model->getAttributeLabel($compareAttribute);
|
$compareValue = $model->getAttributeLabel($compareAttribute);
|
||||||
$options['compareAttribute'] = Html::getInputId($model, $compareAttribute);
|
$options['compareAttribute'] = Html::getInputId($model, $compareAttribute);
|
||||||
|
$options['compareAttributeName'] = Html::getInputName($model, $compareAttribute);
|
||||||
$compareLabel = $compareValueOrAttribute = $model->getAttributeLabel($compareAttribute);
|
$compareLabel = $compareValueOrAttribute = $model->getAttributeLabel($compareAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1506,13 +1506,8 @@ describe('yii.validation', function () {
|
|||||||
describe('with compareAttribute, "==" operator and 2 identical strings', function () {
|
describe('with compareAttribute, "==" operator and 2 identical strings', function () {
|
||||||
it(VALIDATOR_SUCCESS_MESSAGE, function () {
|
it(VALIDATOR_SUCCESS_MESSAGE, function () {
|
||||||
var $form = {
|
var $form = {
|
||||||
data: function () {
|
find: function(){
|
||||||
return {
|
return $input;
|
||||||
attributes: [{
|
|
||||||
"id": "input-id",
|
|
||||||
"input": "#input-id"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var messages = [];
|
var messages = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user