コード例 #1
0
 /**
  * Creates a new Partner model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     // get the instance of the uploaded files.
     $model = new Partner();
     if ($model->load(Yii::$app->request->post())) {
         $ndaname = $model->name . '-NDA';
         $msaname = $model->name . '-MSA';
         $agreementname = $model->name . '-PA';
         //save the actual files into the uploads directory
         $model->ndafile = UploadedFile::getInstance($model, 'ndafile');
         $model->msafile = UploadedFile::getInstance($model, 'msafile');
         $model->agreementfile = UploadedFile::getInstance($model, 'agreementfile');
         $model->ndafile->saveAs('uploads/' . $ndaname . '.' . $model->ndafile->extension);
         $model->msafile->saveAs('uploads/' . $msaname . '.' . $model->msafile->extension);
         $model->agreementfile->saveAs('uploads/' . $agreementname . '.' . $model->agreementfile->extension);
         //save the path in the db column
         $model->nda_file = 'uploads/' . $ndaname . '.' . $model->ndafile->extension;
         $model->msa_file = 'uploads/' . $msaname . '.' . $model->msafile->extension;
         $model->agreement_file = 'uploads/' . $agreementname . '.' . $model->agreementfile->extension;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * Creates a new Partner model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Partner();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #3
0
ファイル: PartnerController.php プロジェクト: vsguts/crm
 /**
  * Creates a new Partner model.
  * If creation is successful, the browser will be redirected to the 'update' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Partner();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #4
0
ファイル: PartnerController.php プロジェクト: xiaoliwang/yii2
 /**
  * Creates a new Partner model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Partner();
     $form = new UploadForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($form->image = UploadedFile::getInstance($form, 'image')) {
             $model->pic = 'image/' . md5($_SERVER['REQUEST_TIME'] . $form->image->baseName) . $_SERVER['REQUEST_TIME'] . '.' . $form->image->extension;
             $form->image->saveAs($model->pic);
             $model->save();
             return $this->redirect(['view', 'id' => $model->id, 'type' => $model->type]);
         } else {
             $form->addError('image', '图片不可为空');
         }
     }
     return $this->render('create', ['model' => $model, 'uploadForm' => $form]);
 }