Commit a4a72033 by Qiang Xue

Fixes #1412: `FileValidator` still triggers `uploadRequired` error in some case…

Fixes #1412: `FileValidator` still triggers `uploadRequired` error in some case when `skipOnEmpty` is true and no upload is provided
parent 17ca07fd
...@@ -6,6 +6,7 @@ Yii Framework 2 Change Log ...@@ -6,6 +6,7 @@ Yii Framework 2 Change Log
- Bug #1265: AssetController does not override 'js' and 'css' for compressed bundles (klimov-paul) - Bug #1265: AssetController does not override 'js' and 'css' for compressed bundles (klimov-paul)
- Bug #1326: The `visible` setting for `DetailView` doesn't work as expected (qiangxue) - Bug #1326: The `visible` setting for `DetailView` doesn't work as expected (qiangxue)
- Bug #1412: `FileValidator` still triggers `uploadRequired` error in some case when `skipOnEmpty` is true and no upload is provided (qiangxue)
- Bug #1446: Logging while logs are processed causes infinite loop (qiangxue) - Bug #1446: Logging while logs are processed causes infinite loop (qiangxue)
- Bug #1497: Localized view files are not correctly returned (mintao) - Bug #1497: Localized view files are not correctly returned (mintao)
- Bug #1500: Log messages exported to files are not separated by newlines (omnilight, qiangxue) - Bug #1500: Log messages exported to files are not separated by newlines (omnilight, qiangxue)
......
...@@ -167,7 +167,7 @@ class FileValidator extends Validator ...@@ -167,7 +167,7 @@ class FileValidator extends Validator
protected function validateValue($file) protected function validateValue($file)
{ {
if (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE) { if (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE) {
return [$this->uploadRequired, []]; return $this->skipOnEmpty ? [] : [$this->uploadRequired, []];
} }
switch ($file->error) { switch ($file->error) {
case UPLOAD_ERR_OK: case UPLOAD_ERR_OK:
......
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