/** * 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(); $searchModel = new RegionSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if ($model->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($model); } $model->attributes = $_POST['Region']; $model->create_at = new \yii\db\Expression('NOW()'); $model->update_at = new \yii\db\Expression('NOW()'); if ($model->save()) { $this->redirect(['index']); } } else { return $this->render('index', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } }