mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 04:37:42 +08:00
Fix #8225: Fixed AJAX validation with checkboxList was only triggered on first select
This commit is contained in:
committed by
Alexander Makarov
parent
d7f69b6676
commit
40fff67aa4
@ -7,6 +7,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #17602: `EmailValidator` with `checkDNS=true` throws `ErrorException` on bad domains on Alpine (batyrmastyr)
|
- Bug #17602: `EmailValidator` with `checkDNS=true` throws `ErrorException` on bad domains on Alpine (batyrmastyr)
|
||||||
- Enh #17607: Added Yii version 3 DI config compatibility (hiqsol)
|
- Enh #17607: Added Yii version 3 DI config compatibility (hiqsol)
|
||||||
- Bug #17606: Fix error in `AssetBundle` when a disabled bundle with custom init() was still published (onmotion)
|
- Bug #17606: Fix error in `AssetBundle` when a disabled bundle with custom init() was still published (onmotion)
|
||||||
|
- Bug #8225: Fixed AJAX validation with checkboxList was only triggered on first select (execut)
|
||||||
- Bug #17597: PostgreSQL 12 and partitioned tables support (batyrmastyr)
|
- Bug #17597: PostgreSQL 12 and partitioned tables support (batyrmastyr)
|
||||||
- Bug #17625: Fix boolean `data` attributes from subkeys rendering in `Html::renderTagAttributes()` (brandonkelly)
|
- Bug #17625: Fix boolean `data` attributes from subkeys rendering in `Html::renderTagAttributes()` (brandonkelly)
|
||||||
|
|
||||||
|
|||||||
@ -876,6 +876,14 @@
|
|||||||
var type = $input.attr('type');
|
var type = $input.attr('type');
|
||||||
if (type === 'checkbox' || type === 'radio') {
|
if (type === 'checkbox' || type === 'radio') {
|
||||||
var $realInput = $input.filter(':checked');
|
var $realInput = $input.filter(':checked');
|
||||||
|
if ($realInput.length > 1) {
|
||||||
|
var values = [];
|
||||||
|
$realInput.each(function(index) {
|
||||||
|
values.push($($realInput.get(index)).val());
|
||||||
|
});
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$realInput.length) {
|
if (!$realInput.length) {
|
||||||
$realInput = $form.find('input[type=hidden][name="' + $input.attr('name') + '"]');
|
$realInput = $form.find('input[type=hidden][name="' + $input.attr('name') + '"]');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,6 +183,28 @@ describe('yii.activeForm', function () {
|
|||||||
$activeForm.yiiActiveForm('updateAttribute', inputId);
|
$activeForm.yiiActiveForm('updateAttribute', inputId);
|
||||||
assert.equal('New value', eventData.value);
|
assert.equal('New value', eventData.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://github.com/yiisoft/yii2/issues/8225
|
||||||
|
|
||||||
|
it('the value of the checkboxes must be an array', function () {
|
||||||
|
var inputId = 'test_checkbox';
|
||||||
|
var $input = $('#' + inputId);
|
||||||
|
|
||||||
|
$activeForm = $('#w1');
|
||||||
|
$activeForm.yiiActiveForm('destroy');
|
||||||
|
$activeForm.yiiActiveForm([
|
||||||
|
{
|
||||||
|
id: inputId,
|
||||||
|
input: '#' + inputId
|
||||||
|
}
|
||||||
|
]).on('afterValidateAttribute', afterValidateAttributeSpy);
|
||||||
|
|
||||||
|
$input.find('input').prop('checked', true);
|
||||||
|
$activeForm.yiiActiveForm('updateAttribute', inputId);
|
||||||
|
var value = eventData.value;
|
||||||
|
assert.isArray(value);
|
||||||
|
assert.deepEqual(['1', '0'], value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('afterValidate', function () {
|
describe('afterValidate', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user