Closed Zhassulan closed 6 years ago
Please, code
form:
action:
public function actionCreate() { $model = new Users (); if ($model->load ( Yii::$app->request->post () )) { if ($model->save ()) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['success' => true]; } return $this->redirect ( [ 'view', 'id' => $model->id] ); } } if (Yii::$app->request->isAjax) { return $this->renderAjax ( 'create', [ 'model' => $model ] ); } else return $this->render ( 'create', [ 'model' => $model ] ); }
index:
Where $model->validate()?
Thanx!
Hello! Why my model is empty saved?