model_id = $model_id; $this->cat_id = $cat_id; $this->categorys = $categorys; $this->fields = json_decode(Yii::$app->cache->get(CacheId::modelFieldCacheId($model_id)),true); } function get($data) { $this->data = $data; $this->id = $data['id']; $info = array(); foreach($this->fields as $field=>$v) { if(!isset($data[$field])) continue; $func = $v['form_type']; $value = $data[$field]; $result = method_exists($this, $func) ? $this->$func($field, $data[$field]) : $data[$field]; if($result !== false) $info[$field] = $result; } return $info; } }?>