public function actionBaredit() { $id = Yii::$app->request->post('id'); $model = AgMnavbar::findOne($id); if ($model === null) { Yii::$app->getSession()->setFlash("info", '编辑失败'); return $this->redirect(['navbar']); } if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->getSession()->setFlash('info', '编辑成功!'); return $this->redirect(['navbar']); } }
/** * 关联二级导航 */ public function getMbar() { return $this->hasMany(AgMnavbar::className(), ['pid' => 'id']); }