Example #1
0
 public function actionAdd()
 {
     $model = new AddForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $tour = $model->add();
         if (!$tour) {
             Yii::$app->session->setFlash('error', 'Ошибка при валидации');
             Yii::error('Ошибка при валидации');
             return $this->goHome();
         }
     }
     return $this->render('add', ['model' => $model]);
 }
Example #2
0
 public function actionAdd()
 {
     $model = new AddForm();
     $load = new UploadForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $tour = $model->add();
         if (!$tour) {
             Yii::$app->session->setFlash('error', 'Ошибка при валидации');
             Yii::error('Ошибка при валидации');
             return $this->goHome();
         }
     }
     if (Yii::$app->request->isPost) {
         $load->imageFiles = UploadedFile::getInstances($load, 'imageFiles');
         if ($load->upload($tour->id)) {
             // file is uploaded successfully
             return $this->redirect('my', 302);
         }
     }
     return $this->render('add', ['model' => $model, 'load' => $load]);
 }