/**
  * Creates a new District model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new District();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->district_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionCreate()
 {
     $model = new District();
     if ($model->load(Yii::$app->request->post())) {
         $image = $model->uploadImage();
         if ($model->save()) {
             if ($image !== false) {
                 $path = $model->getImageFile();
                 $image->saveAs($path);
                 $this->saveThumb($model);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
Example #3
0
 /**
  * Creates a new District model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new District();
     for ($i = 1; $i <= Lang::find()->count(); $i++) {
         $model_content[$i] = new DistrictLang();
         $model_content[$i]['lang_id'] = $i;
         $model_content[$i]['id'] = 0;
     }
     if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($model_content, Yii::$app->request->post()) && Model::validateMultiple($model_content) && $model->save()) {
         foreach ($model_content as $key => $content) {
             $content->id = $model->id;
             $content->lang_id = $key;
             $content->save(false);
         }
         return $this->redirect(['/district']);
     } else {
         return $this->render('create', ['model' => $model, 'model_content' => $model_content]);
     }
 }