backend/controllers/UserController.php
/**
     * Updates an existing User model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     */
Updates an existing User model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
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)
    {
        $model = $this->findModel($id);
        if ($model->load(Yii::$app->request->post())) {
            $model->username=Yii::$app->request->post()['User']['username'];
            $model->email=Yii::$app->request->post()['User']['email'];
            $model->level_user=Yii::$app->request->post()['User']['level_user'];
            $model->setPassword(Yii::$app->request->post()['User']['password_hash']);
            $model->generateAuthKey();
            $model->unit=Yii::$app->request->post()['User']['unit'];
            if ( $model->save()) {
                return $this->redirect(['index']);
            }
            return $this->redirect(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> username = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'username' ] ; $ model -> email = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'email' ] ; $ model -> level_user = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'level_user' ] ; $ model -> setPassword ( Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'password_hash' ] ) ; $ model -> generateAuthKey ( ) ; $ model -> unit = Yii :: $ app -> request -> post ( ) [ 'User' ] [ 'unit' ] ; if ( $ model -> save ( ) ) { return $ this -> redirect ( [ 'index' ] ) ; } return $ this -> redirect ( [ 'index' ] ) ; } else { return $ this -> render ( 'update' , [ 'model' => $ model , ] ) ; } }
Updates an existing User model.
Updates an existing User model .