mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 10:39:59 +08:00 
			
		
		
		
	Fixes #14901: Fixed trim validation for radio/checkbox button
This commit is contained in:
		 Evgeniy Moiseenko
					Evgeniy Moiseenko
				
			
				
					committed by
					
						 Alexander Makarov
						Alexander Makarov
					
				
			
			
				
	
			
			
			 Alexander Makarov
						Alexander Makarov
					
				
			
						parent
						
							001e4c5aed
						
					
				
				
					commit
					b36639b288
				
			| @ -3,6 +3,7 @@ Yii Framework 2 Change Log | ||||
|  | ||||
| 2.0.16 under development | ||||
| ------------------------ | ||||
| - Bug #14901: Fixed trim validation for radio/checkbox button (s1lver) | ||||
| - Bug #16527: Fixed return content for `\yii\widgets\ActiveForm::run()` (carono) | ||||
| - Bug #15826: Fixed JavaScript compareValidator in `yii.validation.js` for attributes not in rules (mgrechanik) | ||||
| - Enh #16365: Added $filterOnFocusOut option for GridView (s1lver) | ||||
|  | ||||
| @ -236,9 +236,15 @@ yii.validation = (function ($) { | ||||
|             } | ||||
|         }, | ||||
|  | ||||
|         trim: function ($form, attribute, options) { | ||||
|         trim: function ($form, attribute, options, value) { | ||||
|             var $input = $form.find(attribute.input); | ||||
|             var value = $input.val(); | ||||
|             var isCheckAble = $input.find('[type=radio]').is('[type=radio]') || $input.find('[type=checkbox]').is('[type=checkbox]'); | ||||
|  | ||||
|             if (!isCheckAble) { | ||||
|                 return value; | ||||
|             } | ||||
|  | ||||
|             value = $input.val(); | ||||
|             if (!options.skipOnEmpty || !pub.isEmpty(value)) { | ||||
|                 value = $.trim(value); | ||||
|                 $input.val(value); | ||||
|  | ||||
| @ -91,7 +91,7 @@ class FilterValidator extends Validator | ||||
|         ValidationAsset::register($view); | ||||
|         $options = $this->getClientOptions($model, $attribute); | ||||
|  | ||||
|         return 'value = yii.validation.trim($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');'; | ||||
|         return 'value = yii.validation.trim($form, attribute, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ', value);'; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|  | ||||
		Reference in New Issue
	
	Block a user