/** * Creates a new Region model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Region(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Region model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { //if(!Yii::$app->user->can('createYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth')); $model = new Region(); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Region model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Region(); for ($i = 1; $i <= Lang::find()->count(); $i++) { $model_content[$i] = new RegionLang(); $model_content[$i]['lang_id'] = $i; $model_content[$i]['id'] = 0; } if (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(['/region']); } else { return $this->render('create', ['model' => $model, 'model_content' => $model_content]); } }