public function actionProfile() { if (!is_null($user = $this->getLoggedUser())) { $profile = new ProfileForm($user); if (Yii::$app->request->isPost && $profile->load(Yii::$app->request->post()) && $profile->validate() && $profile->update($user)) { } return $this->render('profile', ['model' => $profile, 'user' => $user]); } else { return $this->redirect(['site/register']); } }
public function actionUpdate() { $user = $this->findModel(); $model = new ProfileForm($user); if ($model->load(Yii::$app->request->post()) && $model->update()) { return $this->redirect(['profile']); } else { echo 'F**K! Update() does not work!'; if ($model->status == User::SCENARIO_PERSON) { return $this->render('update-person', ['model' => $model]); } elseif ($model->status == User::SCENARIO_COMPANY) { return $this->render('update-company', ['model' => $model]); } else { false; } } }