fixed wrong client validation issue in numbervalidator

fixes #3118
This commit is contained in:
Carsten Brandt
2014-04-23 01:29:19 +02:00
parent 4f6e1d305f
commit 83a63f2346
22 changed files with 101 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ Yii Framework 2 Change Log
- Bug #3042: `yii\widgets\Pjax` should end application right after it finishes responding to a pjax request (qiangxue)
- Bug #3066: `yii\db\mssql\Schema::getTableSchema()` should return null when the table does not exist (qiangxue)
- Bug #3091: Fixed inconsistent treatment of `Widget::run()` when a widget is used as a container and as a self-contained object (qiangxue)
- Bug #3118: Ensure client validation has the same behavior as server side validation for number validator (cebe)
- Bug #3121: `yii\base\Application::bootstrap` may fail to load some components if they are specified as class names (qiangxue)
- Bug #3125: `yii\console\controllers\AssetController` now respects data URL resources (klimov-paul)
- Bug #3128: Fixed the bug that `defaultRoles` set in RBAC manager was not working as specified (qiangxue)

View File

@@ -128,14 +128,18 @@ class NumberValidator extends Validator
];
if ($this->min !== null) {
$options['min'] = $this->min;
// ensure numeric value to make javascript comparison equal to PHP comparison
// https://github.com/yiisoft/yii2/issues/3118
$options['min'] = is_string($this->min) ? (float)$this->min : $this->min;
$options['tooSmall'] = Yii::$app->getI18n()->format($this->tooSmall, [
'attribute' => $label,
'min' => $this->min,
], Yii::$app->language);
}
if ($this->max !== null) {
$options['max'] = $this->max;
// ensure numeric value to make javascript comparison equal to PHP comparison
// https://github.com/yiisoft/yii2/issues/3118
$options['max'] = is_string($this->max) ? (float)$this->max : $this->max;
$options['tooBig'] = Yii::$app->getI18n()->format($this->tooBig, [
'attribute' => $label,
'max' => $this->max,