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 ...@@ -96,6 +96,7 @@ Yii Framework 2 Change Log
- Bug #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery` (stepanselyuk) - 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 #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 #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: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul) - 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) - Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
// whether to perform validation when the user is typing. // whether to perform validation when the user is typing.
validateOnType: false, validateOnType: false,
// number of milliseconds that the validation should be delayed when a user is typing in the input field. // 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. // whether to enable AJAX-based validation.
enableAjaxValidation: false, enableAjaxValidation: false,
// function (attribute, value, messages), the client-side validation function. // function (attribute, value, messages), the client-side validation function.
...@@ -411,7 +411,7 @@ ...@@ -411,7 +411,7 @@
if (attribute.validateOnType) { if (attribute.validateOnType) {
$input.on('keyup.yiiActiveForm', function () { $input.on('keyup.yiiActiveForm', function () {
if (attribute.value !== getValue($form, attribute)) { if (attribute.value !== getValue($form, attribute)) {
validateAttribute($form, attribute, false); validateAttribute($form, attribute, false, attribute.valdationDelay);
} }
}); });
} }
...@@ -421,7 +421,7 @@ ...@@ -421,7 +421,7 @@
findInput($form, attribute).off('.yiiActiveForm'); findInput($form, attribute).off('.yiiActiveForm');
}; };
var validateAttribute = function ($form, attribute, forceValidate) { var validateAttribute = function ($form, attribute, forceValidate, validationDelay) {
var data = $form.data('yiiActiveForm'); var data = $form.data('yiiActiveForm');
if (forceValidate) { if (forceValidate) {
...@@ -451,7 +451,7 @@ ...@@ -451,7 +451,7 @@
} }
}); });
methods.validate.call($form); methods.validate.call($form);
}, attribute.validationDelay); }, validationDelay ? validationDelay : 200);
}; };
/** /**
......
...@@ -111,8 +111,8 @@ class ActiveField extends Component ...@@ -111,8 +111,8 @@ class ActiveField extends Component
*/ */
public $validateOnType; public $validateOnType;
/** /**
* @var integer number of milliseconds that the validation should be delayed when the input field * @var integer number of milliseconds that the validation should be delayed when the user types in the field
* is changed or the user types in the field. * and [[validateOnType]] is set true.
* If not set, it will take the value of [[ActiveForm::validationDelay]]. * If not set, it will take the value of [[ActiveForm::validationDelay]].
*/ */
public $validationDelay; public $validationDelay;
...@@ -747,7 +747,7 @@ class ActiveField extends Component ...@@ -747,7 +747,7 @@ class ActiveField extends Component
'validateOnChange' => true, 'validateOnChange' => true,
'validateOnBlur' => true, 'validateOnBlur' => true,
'validateOnType' => false, 'validateOnType' => false,
'validationDelay' => 200, 'validationDelay' => 500,
'encodeError' => true, 'encodeError' => true,
'error' => '.help-block', 'error' => '.help-block',
]); ]);
......
...@@ -131,11 +131,11 @@ class ActiveForm extends Widget ...@@ -131,11 +131,11 @@ class ActiveForm extends Widget
*/ */
public $validateOnType = false; public $validateOnType = false;
/** /**
* @var integer number of milliseconds that the validation should be delayed when an input field * @var integer number of milliseconds that the validation should be delayed when the user types in the field
* is changed or 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. * 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. * @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