Ejemplo n.º 1
0
 public function actionUpdate()
 {
     if (($model = UpdateUser::findOne(\Yii::$app->user->id)) !== null) {
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     } else {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             $this->redirect(['index']);
         } else {
             return $this->render('update', ['model' => $model]);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     if (($model = UpdateUser::findOne($id)) !== null) {
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->Id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }