diff --git a/framework/behaviors/AttributeTypecastBehavior.php b/framework/behaviors/AttributeTypecastBehavior.php index e2bde1b9a98..b4194634970 100644 --- a/framework/behaviors/AttributeTypecastBehavior.php +++ b/framework/behaviors/AttributeTypecastBehavior.php @@ -235,7 +235,7 @@ public function typecastAttributes($attributeNames = null) } foreach ($attributeTypes as $attribute => $type) { - $value = $this->owner->{$attribute}; + $value = $this->owner->hasAttribute($attribute) ? $this->owner->{$attribute} : null; if ($this->skipOnNull && $value === null) { continue; }