public function actionRegister() { $errors = null; $model = new UserForm(); if (Yii::$app->request->isPost) { $model->setAttributes(Yii::$app->request->post()); if ($model->validate()) { $user = new User(); $user->setAttributes($model->getAttributes()); $user->setPassword($model->password); $user->generateAuthKey(); $save = $user->save(); if ($save) { $purse = new Purse(); $purse->user_id = $user->id; $purse->active = 1; $purse->balance = 0; $purse->name = "Основной"; $purse->save(); $login = Yii::$app->user->login($user, 3600 * 24 * 14); if ($login) { return $this->goHome(); } } } else { $errors = $model->getErrors(); } } return $this->renderPartial('register', ['errors' => $errors, 'model' => $model]); }
public function actionUser() { $model = new UserForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { Yii::$app->session->setFlash('success', 'Data entered'); // Save to Db echo "<pre>"; print_r($model->getAttributes()); echo "</pre>"; die; } return $this->render('userform', array('model' => $model)); }