Skip to content

Commit

Permalink
Fixed yii\behaviors\AttributeTypecastBehavior::$attributeTypes auto…
Browse files Browse the repository at this point in the history
…-detection fails for rule, which specify attribute with '!' prefix
  • Loading branch information
klimov-paul committed Jan 3, 2018
1 parent b44bbd6 commit 2a742ce
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Yii Framework 2 Change Log
- Bug #15380: `FormatConverter::convertDateIcuToPhp()` now converts `a` ICU symbols to `A` (brandonkelly)
- Bug #15407: Fixed rendering rows with associative arrays in `yii\console\widgets\Table` (dmrogin)
- Bug #15432: Fixed wrong value being set in `yii\filters\RateLimiter::checkRateLimit()` resulting in wrong `X-Rate-Limit-Reset` header value (bizley)
- Bug #15440: Fixed `yii\behaviors\AttributeTypecastBehavior::$attributeTypes` auto-detection fails for rule, which specify attribute with '!' prefix (klimov-paul)
- Enh #3087: Added `yii\helpers\BaseHtml::error()` "errorSource" option to be able to customize errors display (yanggs07, developeruz, silverfire)
- Enh #3250: Added support for events partial wildcard matching (klimov-paul)
- Enh #5515: Added default value for `yii\behaviors\BlameableBehavior` for cases when the user is guest (dmirogin)
Expand Down
2 changes: 1 addition & 1 deletion framework/behaviors/AttributeTypecastBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected function detectAttributeTypes()

if ($type !== null) {
foreach ((array) $validator->attributes as $attribute) {
$attributeTypes[$attribute] = $type;
$attributeTypes[ltrim($attribute, '!')] = $type;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function testAutoDetectAttributeTypes()
->addRule('name', 'string')
->addRule('amount', 'integer')
->addRule('price', 'number')
->addRule('isActive', 'boolean');
->addRule('!isActive', 'boolean');

$behavior = new AttributeTypecastBehavior();

Expand Down

0 comments on commit 2a742ce

Please sign in to comment.