/** * 新建 * @return {[type]} [description] * @version 1.0 2016-03-09T15:42:23+0800 * @author cnzhangxl@foxmail.com */ public function actionCreate() { $model = new Piece(['scenario' => 'create']); $model->mg_id = Yii::$app->user->id; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }