コード例 #1
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->checkExist()) {
             LuLu::setFalsh('warning', $model->variable . ':已经存在');
             return $this->refresh();
         }
         $model->save();
         CacheUtility::createVariableCache();
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
コード例 #2
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->checkExist()) {
             LuLu::setFalsh('warning', $model->id . ':已经存在');
             return $this->refresh();
         }
         if ($model->oldAttributes['id'] !== $model->id) {
             Dict::updateAll(['category_id' => $model->id], ['category_id' => $model->oldAttributes['id']]);
         }
         $model->save();
         return $this->redirect(['index', 'id' => $model->id]);
     } else {
         $locals = [];
         $locals['model'] = $model;
         return $this->render('update', $locals);
     }
 }