Browse Source

Fix #18323: Fix client validation of RadioList when there are disabled items

bizley-patch-1
Toir Tuychiev 4 years ago committed by GitHub
parent
commit
2650948e87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 1
      framework/CHANGELOG.md
  3. 3
      framework/assets/yii.activeForm.js
  4. 13
      tests/js/data/yii.activeForm.html
  5. 13
      tests/js/tests/yii.activeForm.test.js

1
.gitignore vendored

@ -47,3 +47,4 @@ phpunit.phar
# NPM packages
/node_modules
.env
package-lock.json

1
framework/CHANGELOG.md

@ -4,6 +4,7 @@ Yii Framework 2 Change Log
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 #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)

3
framework/assets/yii.activeForm.js

@ -329,7 +329,8 @@
this.$form = $form;
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;
}
// validate markup for select input

13
tests/js/data/yii.activeForm.html

@ -35,3 +35,16 @@
</div>
</fieldset>
</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>

13
tests/js/tests/yii.activeForm.test.js

@ -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 () {

Loading…
Cancel
Save