Use consultnn/yii2-validators instead AttributeTypeBehavior
Extension of the class yii\base\Behavior
###Class AttributeTypeBehavior to converts attribute for all simple types and mongoDb types.
Number and boolean type taken from the corresponding attribute validator
public function behaviors()
{
return [
[
'class' => AttributeTypeBehavior::className(),
'attributes' => [
'_id' => AttributeTypeBehavior::TYPE_MONGO_ID,
'attribute1' => [AttributeTypeBehavior::TYPE_ARRAY_OF => AttributeTypeBehavior::TYPE_INTEGER]
]
]
];
}
Default events ActiveRecord::EVENT_BEFORE_INSERT
, ActiveRecord::EVENT_BEFORE_UPDATE
Add attributes => ['date' => 'MongoDate']
Add a method to the class AttributeTypeBehavior:
private function setMongoDate(&$value)
{
$value = new \MongoDate(strtotime($value));
}
###Class TreeViewBehavior to dynamically update the model attributes with the use of plug-in jstree
Events ActiveRecord::EVENT_BEFORE_INSERT
, ActiveRecord::EVENT_BEFORE_UPDATE
, ActiveRecord::EVENT_BEFORE_DELETE