/** * Creates a new Entidad model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Entidad(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Entidad model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (Yii::$app->user->can('admin') || Yii::$app->user->can('staff')) { $model = new Entidad(); if (Yii::$app->request->isAjax && $model->load($_POST)) { Yii::$app->response->format = 'json'; return \yii\widgets\ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } } }