Exemplo n.º 1
0
 public function actionEdit()
 {
     $request = Yii::$app->request;
     $user = User::findOne($request->get('id'));
     $model = new UserForm();
     $model->attributes = $user->attributes;
     if ($model->load($request->post()) && $model->validate()) {
         //Overall assignment the attributes of $user must be safe attributes
         $user->attributes = $model->attributes;
         // var_dump($model->attributes);
         // var_dump($user->attributes);exit();
         if ($user->save()) {
             $this->redirect(array('index'));
         } else {
         }
     } else {
         if ($model->hasErrors()) {
             // foreach($model->getErrors() as $error){
             // 	var_dump($error,false);
             // }
         }
     }
     return $this->render('edit', ['model' => $model]);
 }