示例#1
0
 /**
  * Save or update document
  *
  * @param null $id
  *
  * @throws \yii\web\HttpException
  */
 public function actionSave($id = null)
 {
     if (null !== $id) {
         $model = Document::findOne(['id' => $id]);
         if (null === $model) {
             throw new HttpException(404);
         }
     } else {
         $model = new Document();
     }
     if ($model->load(\Yii::$app->request->post())) {
         if ($document_id = $model->saveDocument()) {
             $this->redirect(Url::toRoute(['/document/default/view/', 'id' => $document_id]));
         }
     }
 }