50], ['type', 'in', 'range' => array_keys(self::getTypeList())], ['value', 'filter', 'filter' => function ($val) { if ($this->type == 'checkbox') { return serialize($val); } return $val; }, 'skipOnEmpty' => true], [['value', 'description', 'extra'], 'string'], ]; } public function afterFind() { parent::afterFind(); if ($this->type == 'checkbox' && !empty($this->value)) { $this->value = unserialize($this->value); } } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => '配置名', 'value' => '配置值', 'description' => '配置描述', 'type' => '配置类型', 'extra' => '配置项', 'group' => '分组', ]; } public function behaviors() { return [ TimestampBehavior::className(), [ 'class' => CacheInvalidateBehavior::className(), 'tags' => [ \Yii::$app->config->cacheTag ] ] ]; } public static function getTypeList() { return \Yii::$app->config->get('config_type_list'); } }