mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 02:28:35 +08:00 
			
		
		
		
	Skip validation if file input does not exist (#13977)
This commit is contained in:
		 Evgeniy Moiseenko
					Evgeniy Moiseenko
				
			
				
					committed by
					
						 Alexander Makarov
						Alexander Makarov
					
				
			
			
				
	
			
			
			 Alexander Makarov
						Alexander Makarov
					
				
			
						parent
						
							0f0e895475
						
					
				
				
					commit
					46c50e43c4
				
			| @ -4,6 +4,7 @@ Yii Framework 2 Change Log | |||||||
| 2.0.16 under development | 2.0.16 under development | ||||||
| ------------------------ | ------------------------ | ||||||
|  |  | ||||||
|  | - Bug #13977: Skip validation if file input does not exist (RobinKamps, s1lver) | ||||||
| - Bug #16183: Fixed when `yii\helpers\BaseFileHelper` sometimes returned wrong value (samdark, SilverFire, OndrejVasicek) | - Bug #16183: Fixed when `yii\helpers\BaseFileHelper` sometimes returned wrong value (samdark, SilverFire, OndrejVasicek) | ||||||
| - Bug #13932: Fix number validator attributes comparison (uaoleg, s1lver) | - Bug #13932: Fix number validator attributes comparison (uaoleg, s1lver) | ||||||
| - Bug #14039, #16636: Fixed validation for disabled inputs (s1lver, omzy83) | - Bug #14039, #16636: Fixed validation for disabled inputs (s1lver, omzy83) | ||||||
|  | |||||||
| @ -376,13 +376,15 @@ yii.validation = (function ($) { | |||||||
|             return []; |             return []; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Continue validation if file input does not exist |         var fileInput = $(attribute.input, attribute.$form).get(0); | ||||||
|  |  | ||||||
|  |         // Skip validation if file input does not exist | ||||||
|         // (in case file inputs are added dynamically and no file input has been added to the form) |         // (in case file inputs are added dynamically and no file input has been added to the form) | ||||||
|         if (typeof $(attribute.input, attribute.$form).get(0) === "undefined") { |         if (typeof fileInput === "undefined") { | ||||||
|             return []; |             return []; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         var files = $(attribute.input, attribute.$form).get(0).files; |         var files = fileInput.files; | ||||||
|         if (!files) { |         if (!files) { | ||||||
|             messages.push(options.message); |             messages.push(options.message); | ||||||
|             return []; |             return []; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user