I’m using the new AttributeTypecastBehavior from 2.0.10 as shown in the release notes:
use yii\behaviors\AttributeTypecastBehavior;
class Item extends \yii\db\ActiveRecord
{
public function rules()
{
return [
['amount', 'integer'],
['price', 'number'],
['is_active', 'boolean'],
];
}
public function behaviors()
{
return [
'typecast' => [
'class' => AttributeTypecastBehavior::className(),
// 'attributeTypes' will be composed automatically according to `rules()`
],
];
}
// ...
}
However I get:
Call to a member function getValidators() on null in vendor/yiisoft/yii2/behaviors/AttributeTypecastBehavior.php Line 273.
Looks like there is a problem attaching the behavior to the class. Does anyone else have this problem? I’ve got several other behaviors attached to the class and they work fine.