consultnn/yii2-behaviors
最新稳定版本:1.0.3
Composer 安装命令:
composer require consultnn/yii2-behaviors
包简介
README 文档
README
Use consultnn/yii2-validators instead AttributeTypeBehavior
yii2-behaviors
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
Example of a call from the model.
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
Example add convert MongoDate type.
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
统计信息
- 总下载量: 95
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-08