Skip to content

Commit

Permalink
Fixes yiisoft#6361: Added validateAttribute() to `yii.activeForm.js…
Browse files Browse the repository at this point in the history
…` to support manually triggering data validation of an input
  • Loading branch information
qiangxue committed Feb 2, 2015
1 parent a438335 commit 4dcbe83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Yii Framework 2 Change Log
- Bug #7074: `yii\data\ArrayDataProvider` did not correctly handle the case `Pagination::pageSize = 0` (kirsenn, qiangxue)
- Enh #5663: Added support for using `data-params` to specify additional form data to be submitted via the `data-method` approach (usualdesigner, qiangxue)
- Enh #6106: Added ability to specify `encode` for each item of `yii\widgets\Breadcrumbs` (samdark, aleksanderd)
- Enh #6361: Added `validateAttribute()` to `yii.activeForm.js` to support manually triggering data validation of an input (Alex-Code, qiang)
- Enh #6493: Added support for the `Access-Control-Expose-Headers` header by `yii\filters\Cors` (usualdesigner)
- Enh #6697: Added `yii\helpers\Url::current()` method that allows adding or removing parameters from current URL (samdark, callmez)
- Enh #6852: Added `yii\helpers\BaseHtmlPurifier::helpers()` in order to be able to configure `HtmlPurifier` helper globally via subclassing (Alex-Code)
Expand Down
12 changes: 9 additions & 3 deletions framework/assets/yii.activeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@
return attribute;
},

// manually trigger the validation of the attribute with the specified ID
validateAttribute: function (id) {
var attribute = methods.find(id);
if (attribute != undefined) {
validateAttribute($(this), attribute, true);
}
},

// find an attribute config based on the specified attribute ID
find: function (id) {
var attributes = $(this).data('yiiActiveForm').attributes,
Expand All @@ -251,6 +259,7 @@
return this.data('yiiActiveForm');
},

// validate all applicable inputs in the form
validate: function () {
var $form = $(this),
data = $form.data('yiiActiveForm'),
Expand Down Expand Up @@ -413,9 +422,6 @@
}
});
}
$input.on('forceValidate.yiiActiveForm', function() {
validateAttribute($form, attribute, true);
});
};

var unwatchAttribute = function ($form, attribute) {
Expand Down

0 comments on commit 4dcbe83

Please sign in to comment.