mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 18:47:33 +08:00 
			
		
		
		
	Fix #18323: Fix client validation of RadioList when there are disabled items
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -47,3 +47,4 @@ phpunit.phar | |||||||
| # NPM packages | # NPM packages | ||||||
| /node_modules | /node_modules | ||||||
| .env | .env | ||||||
|  | package-lock.json | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ Yii Framework 2 Change Log | |||||||
| 2.0.42 under development | 2.0.42 under development | ||||||
| ------------------------ | ------------------------ | ||||||
|  |  | ||||||
|  | - Bug #18323: Fix client validation of RadioList when there are disabled items (toir427) | ||||||
| - Enh #18534: Added `prepareSearchQuery` property in `yii\rest\IndexAction` (programmis) | - Enh #18534: Added `prepareSearchQuery` property in `yii\rest\IndexAction` (programmis) | ||||||
| - Enh #18566: Throw the original exception when `yii\web\Controller::bindInjectedParams()` catches HttpException (pigochu) | - Enh #18566: Throw the original exception when `yii\web\Controller::bindInjectedParams()` catches HttpException (pigochu) | ||||||
| - Bug #18574: Fix `yii\web\DbSession` to use the correct db if strict mode is used (Mignar) | - Bug #18574: Fix `yii\web\DbSession` to use the correct db if strict mode is used (Mignar) | ||||||
|  | |||||||
| @ -329,7 +329,8 @@ | |||||||
|                 this.$form = $form; |                 this.$form = $form; | ||||||
|                 var $input = findInput($form, this); |                 var $input = findInput($form, this); | ||||||
|  |  | ||||||
|                 if ($input.is(':disabled')) { |                 var disabled = $input.toArray().reduce((result, next) => result && $(next).is(':disabled'), true); | ||||||
|  |                 if (disabled) { | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|                 // validate markup for select input |                 // validate markup for select input | ||||||
|  | |||||||
| @ -35,3 +35,16 @@ | |||||||
|         </div> |         </div> | ||||||
|     </fieldset> |     </fieldset> | ||||||
| </form> | </form> | ||||||
|  |  | ||||||
|  | <form id="w2"> | ||||||
|  |     <div class="form-group required"> | ||||||
|  |         <label class="control-label">Test radio</label> | ||||||
|  |         <input type="hidden" name="Test[radio]" value=""> | ||||||
|  |         <div id="radioList" aria-required="true"> | ||||||
|  |             <label><input type="radio" name="Test[radio]" disabled> Test 1</label> | ||||||
|  |             <label><input type="radio" name="Test[radio]"> Test 2</label> | ||||||
|  |             <label><input type="radio" name="Test[radio]"> Test 3</label> | ||||||
|  |         </div> | ||||||
|  |         <div class="help-block"></div> | ||||||
|  |     </div> | ||||||
|  | </form> | ||||||
|  | |||||||
| @ -104,6 +104,19 @@ describe('yii.activeForm', function () { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         describe('if at least one of the items is disabled', function () { | ||||||
|  |             it('validate radioList', function () { | ||||||
|  |                 $activeForm = $('#w2'); | ||||||
|  |                 $activeForm.yiiActiveForm({ | ||||||
|  |                     id: 'radioList', | ||||||
|  |                     input: '#radioList' | ||||||
|  |                 }); | ||||||
|  |                 $activeForm.yiiActiveForm('validate'); | ||||||
|  |  | ||||||
|  |                 assert.isFalse($activeForm.data('yiiActiveForm').validated); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     describe('resetForm method', function () { |     describe('resetForm method', function () { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Toir Tuychiev
					Toir Tuychiev