public function actionCreate($catid, $pid = 0) { $model = new Dict(); $model->parent_id = $pid; $model->category_id = $catid; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index', 'pid' => $pid, 'catid' => $catid]); } else { $locals = []; $locals['model'] = $model; $locals['parent'] = $this->findModel($pid); $locals['parents'] = Dict::getParents($pid); $locals['category'] = DictCategory::findOne($catid); return $this->render('create', $locals); } }