Commit a187d47a by Qiang Xue

Fixes #5049: `ActiveForm::validationDelay` should be applied to user types only

parent 8d082c11
......@@ -96,6 +96,7 @@ Yii Framework 2 Change Log
- Bug #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery` (stepanselyuk)
- Bug #5001: `yii\rest\CreateAction`, `yii\rest\UpdateAction` and `yii\rest\DeleteAction` should throw 500 error if the model operation returns false without validation errors (qiangxue)
- Bug #5039: `UniqueValidator` and `ExistValidator` did not respect query conditions added by default scope (qiangxue)
- Bug #5049: `ActiveForm::validationDelay` should be applied to user types only (qiangxue)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul)
- Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
......
......@@ -145,7 +145,7 @@
// whether to perform validation when the user is typing.
validateOnType: false,
// number of milliseconds that the validation should be delayed when a user is typing in the input field.
validationDelay: 200,
validationDelay: 500,
// whether to enable AJAX-based validation.
enableAjaxValidation: false,
// function (attribute, value, messages), the client-side validation function.
......@@ -411,7 +411,7 @@
if (attribute.validateOnType) {
$input.on('keyup.yiiActiveForm', function () {
if (attribute.value !== getValue($form, attribute)) {
validateAttribute($form, attribute, false);
validateAttribute($form, attribute, false, attribute.valdationDelay);
}
});
}
......@@ -421,7 +421,7 @@
findInput($form, attribute).off('.yiiActiveForm');
};
var validateAttribute = function ($form, attribute, forceValidate) {
var validateAttribute = function ($form, attribute, forceValidate, validationDelay) {
var data = $form.data('yiiActiveForm');
if (forceValidate) {
......@@ -451,7 +451,7 @@
}
});
methods.validate.call($form);
}, attribute.validationDelay);
}, validationDelay ? validationDelay : 200);
};
/**
......
......@@ -111,8 +111,8 @@ class ActiveField extends Component
*/
public $validateOnType;
/**
* @var integer number of milliseconds that the validation should be delayed when the input field
* is changed or the user types in the field.
* @var integer number of milliseconds that the validation should be delayed when the user types in the field
* and [[validateOnType]] is set true.
* If not set, it will take the value of [[ActiveForm::validationDelay]].
*/
public $validationDelay;
......@@ -747,7 +747,7 @@ class ActiveField extends Component
'validateOnChange' => true,
'validateOnBlur' => true,
'validateOnType' => false,
'validationDelay' => 200,
'validationDelay' => 500,
'encodeError' => true,
'error' => '.help-block',
]);
......
......@@ -131,11 +131,11 @@ class ActiveForm extends Widget
*/
public $validateOnType = false;
/**
* @var integer number of milliseconds that the validation should be delayed when an input field
* is changed or the user types in the field.
* @var integer number of milliseconds that the validation should be delayed when the user types in the field
* and [[validateOnType]] is set true.
* If [[ActiveField::validationDelay]] is set, its value will take precedence for that input field.
*/
public $validationDelay = 200;
public $validationDelay = 500;
/**
* @var string the name of the GET parameter indicating the validation request is an AJAX request.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment