Exemplo n.º 1
0
 public function actionUpdate()
 {
     $userId = Yii::app()->user->id;
     $profilesModel = UserApi::getUserProfileDetails($userId);
     //$credentialsModel=UserApi::getUserCredentials($userId);
     $this->performAjaxValidation(array($profilesModel));
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'update-form') {
         echo CActiveForm::validate(array($profilesModel));
         Yii::app()->end();
     }
     if (isset($_POST['UserProfiles'])) {
         // save here
         $profilesModel = UserApi::populateProfilesModel($_POST['UserProfiles'], 'update');
         $profResult = $profilesModel->validate(array('first_name', 'last_name', 'gender', 'address_line1', 'address_line2', 'country_id', 'state_id', 'city_id', 'zip', 'mobile', 'telephone', 'agree, verifyCode'));
         if ($profResult) {
             $result = true;
             $models = UserApi::updateUser($profilesModel, $userId);
             if ($models) {
                 Yii::app()->user->setFlash('success', "Your Account Has been Updated");
                 $this->redirect('/dashboard');
             }
         }
     }
     $this->render('update', array('profilesModel' => $profilesModel));
 }