/** * Creates a new Solicitante model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($submit = false) { $model = new Solicitante(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && $submit == false) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { if ($model->save()) { $model->refresh(); Yii::$app->response->format = Response::FORMAT_JSON; return ['message' => '¡Éxito!']; } else { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } } return $this->renderAjax('create', ['model' => $model]); }