示例#1
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load($_POST)) {
         $parentIds = Channel::getParentIds($model['parent_id']);
         if (in_array($model['id'], $parentIds)) {
             LuLu::setErrorMessage('不能设置父节点为当前节点的子节点');
             return $this->redirect(['update', 'id' => $id]);
         }
         $model->save();
         CacheUtility::createChannelCache();
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['tableList'] = CommonUtility::getTables();
         $locals['channelTpls'] = $this->getTpl('channel_');
         $locals['listTpls'] = $this->getTpl('list_');
         $locals['detailTpls'] = $this->getTpl('detail_');
         return $this->render('update', $locals);
     }
 }