Commit da544b26 by Qiang Xue

Fixes #4519: `yii\base\Model::isAttributeRequired()` should check if the `when`…

Fixes #4519: `yii\base\Model::isAttributeRequired()` should check if the `when` option of the validator is set
parent 45ee387f
...@@ -76,6 +76,7 @@ Yii Framework 2 Change Log ...@@ -76,6 +76,7 @@ Yii Framework 2 Change Log
- Bug #4469: Make `Security::compareString()` timing depend only on length of `$actual` input and add unit test. (tom--) - Bug #4469: Make `Security::compareString()` timing depend only on length of `$actual` input and add unit test. (tom--)
- Bug #4470: Avoid endless loop when exporting logs with low values of flushInterval and eportInterval (cebe) - Bug #4470: Avoid endless loop when exporting logs with low values of flushInterval and eportInterval (cebe)
- Bug #4514: Fixed Request class crashing when empty CSRF token value is sent in cookie (cebe) - Bug #4514: Fixed Request class crashing when empty CSRF token value is sent in cookie (cebe)
- Bug #4519: `yii\base\Model::isAttributeRequired()` should check if the `when` option of the validator is set (thiagotalma)
- 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)
......
...@@ -442,7 +442,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab ...@@ -442,7 +442,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
public function isAttributeRequired($attribute) public function isAttributeRequired($attribute)
{ {
foreach ($this->getActiveValidators($attribute) as $validator) { foreach ($this->getActiveValidators($attribute) as $validator) {
if ($validator instanceof RequiredValidator && !$validator->when) { if ($validator instanceof RequiredValidator && $validator->when === null) {
return true; return true;
} }
} }
......
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