mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-01 03:26:36 +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 | ||||||
|  | |||||||
| @ -34,4 +34,17 @@ | |||||||
|             <div class="help-block"></div> |             <div class="help-block"></div> | ||||||
|         </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 () { | ||||||
| @ -228,12 +241,12 @@ describe('yii.activeForm', function () { | |||||||
|                     $input = $('#' + inputId); |                     $input = $('#' + inputId); | ||||||
|  |  | ||||||
|                 $activeForm = $('#w0'); |                 $activeForm = $('#w0'); | ||||||
|               $activeForm.yiiActiveForm( |                 $activeForm.yiiActiveForm( | ||||||
|                 [{ |                     [{ | ||||||
|                   "id": inputId, |                         "id": inputId, | ||||||
|                   "name": "name", |                         "name": "name", | ||||||
|                   input: '#' + inputId |                         input: '#' + inputId | ||||||
|                 }], []).on('afterValidate', afterValidateSpy); |                     }], []).on('afterValidate', afterValidateSpy); | ||||||
|  |  | ||||||
|                 $activeForm.yiiActiveForm('validate'); |                 $activeForm.yiiActiveForm('validate'); | ||||||
|                 assert.notEqual(null, eventData); |                 assert.notEqual(null, eventData); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Toir Tuychiev
					Toir Tuychiev