/** * 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->created_at = date("Y-m-d H:i:s"); $model->updated_at = date("Y-m-d H:i:s"); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['create']); } } else { $user = UserAccount::find()->select('id, username')->all(); $regions = Region::find()->select('id,title')->all(); return $this->render('create', ['model' => $model, 'user' => $user, 'regions' => $regions]); } }