Ejemplo n.º 1
0
 public function run($chnid)
 {
     $currentChannel = Channel::findOne($chnid);
     $this->currentTableName = $currentChannel['table'];
     $model = new DefaultContent($currentChannel['table']);
     $model->setIsNewRecord(true);
     if ($model->load($_POST)) {
         $this->saveContent($model, true);
         return $this->redirect(['manager', 'chnid' => $chnid]);
     } else {
         $locals = $this->initContent($model, $currentChannel);
         $tplName = $this->getTpl($chnid, 'create');
         return $this->render($tplName, $locals);
     }
 }
Ejemplo n.º 2
0
 public function run($chnid, $id)
 {
     $currentChannel = Channel::findOne($chnid);
     $this->currentTableName = $currentChannel['table'];
     $attValues = $this->findModel($id);
     $model = new DefaultContent($currentChannel['table']);
     $model->setIsNewRecord(false);
     $model->attributes = $attValues;
     if ($model->load($_POST)) {
         $this->saveContent($model);
         return $this->redirect(['index', 'chnid' => $chnid]);
     } else {
         $locals = [];
         $locals['model'] = $model;
         $locals['chnid'] = $chnid;
         $locals['currentChannel'] = $currentChannel;
         $locals['fields'] = DefineTableField::findAll(['table' => $currentChannel['table'], 'is_sys' => 0]);
         $tplName = $this->getTpl($chnid, 'update');
         return $this->render($tplName, $locals);
     }
 }