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:
		 Mikhail
					Mikhail
				
			
				
					committed by
					
						 Alexander Makarov
						Alexander Makarov
					
				
			
			
				
	
			
			
			 Alexander Makarov
						Alexander Makarov
					
				
			
						parent
						
							71424a42fa
						
					
				
				
					commit
					1ad85c640b
				
			| @ -4,6 +4,7 @@ Yii Framework 2 Change Log | ||||
| 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 #14289: Added `yii\db\Command::executeResetSequence()` to work with Oracle (CedricYii) | ||||
| - Enh #9133: Added `yii\behaviors\OptimisticLockBehavior` (tunecino) | ||||
|  | ||||
| @ -274,12 +274,11 @@ yii.validation = (function ($) { | ||||
|             if (options.compareAttribute === undefined) { | ||||
|                 compareValue = options.compareValue; | ||||
|             } else { | ||||
|                 var attributes = $form.data('yiiActiveForm').attributes | ||||
|                 for (var i = attributes.length - 1; i >= 0; i--) { | ||||
|                     if (attributes[i].id === options.compareAttribute) { | ||||
|                         compareValue = $(attributes[i].input).val(); | ||||
|                     } | ||||
|                 var $target = $('#' + options.compareAttribute); | ||||
|                 if (!$target.length) { | ||||
|                     $target = $form.find('[name="' + options.compareAttributeName + '"]'); | ||||
|                 } | ||||
|                 compareValue = $target.val();                 | ||||
|             } | ||||
|  | ||||
|             if (options.type === 'number') { | ||||
|  | ||||
| @ -248,6 +248,7 @@ class CompareValidator extends Validator | ||||
|             $compareAttribute = $this->compareAttribute === null ? $attribute . '_repeat' : $this->compareAttribute; | ||||
|             $compareValue = $model->getAttributeLabel($compareAttribute); | ||||
|             $options['compareAttribute'] = Html::getInputId($model, $compareAttribute); | ||||
|             $options['compareAttributeName'] = Html::getInputName($model, $compareAttribute); | ||||
|             $compareLabel = $compareValueOrAttribute = $model->getAttributeLabel($compareAttribute); | ||||
|         } | ||||
|  | ||||
|  | ||||
| @ -1506,13 +1506,8 @@ describe('yii.validation', function () { | ||||
|         describe('with compareAttribute, "==" operator and 2 identical strings', function () { | ||||
|             it(VALIDATOR_SUCCESS_MESSAGE, function () { | ||||
|                 var $form = { | ||||
|                     data: function () { | ||||
|                         return { | ||||
|                             attributes: [{ | ||||
|                                 "id": "input-id", | ||||
|                                 "input": "#input-id" | ||||
|                             }] | ||||
|                         } | ||||
|                     find: function(){ | ||||
|                         return $input; | ||||
|                     } | ||||
|                 }; | ||||
|                 var messages = []; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user