public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { $locals = []; $locals['model'] = $model; $locals['catid'] = $model->category_id; $locals['categories'] = PageCategory::getAllCategories(); $locals['tpls'] = CommonUtility::getFrontViews('page', 'detail_'); return $this->render('update', $locals); } }
private function getTpl($prefix) { $ret = []; $fiels = CommonUtility::getFrontViews(['content', 'model_default'], $prefix); foreach ($fiels as $file) { $ret[] = ['name' => $file, 'table' => '默认模板(model_default)']; } $tables = CommonUtility::getTables(); foreach ($tables as $table) { $fiels = CommonUtility::getFrontViews(['content', $table['table_name']], $prefix); foreach ($fiels as $file) { $ret[] = ['name' => $file, 'table' => $table['name'] . '(' . $table . ')']; } } return $ret; }