user/controllers/UsersController.php
public function editAction()
    {
        $this->view->disable();
        $id     = $this->request->getPost('hidden_id');    
        $user   = Users::findFirstById($id);
        $msg    = "";
        if (!$user) {
            $alert = "sukses";
            $msg .= "User was not found";
        }

        if ($this->request->isPost()) {

            $user->assign([
                'name' => $this->request->getPost('name', 'striptags'),
                'profilesId' => $this->request->getPost('profile', 'int'),
                'email' => $this->request->getPost('email', 'email'),
                'banned' => $this->request->getPost('banned'),
                'suspended' => $this->request->getPost('suspended'),
                'active' => $this->request->getPost('active')
            ]);
            
            if (!$user->save()) {
                $alert = "error";
                foreach($user->getMessages() as $message)
                {
                    $msg .= $message ." ";
                }
            } else {
                $alert = "sukses";
                $msg .= "User was updated successfully";
            }
        }

        $response = new \Phalcon\Http\Response();
        $response->setContentType('application/json', 'UTF-8');
        $response->setJsonContent(array('_id' => $this->request->getPost("name"),'alert' => $alert, 'msg' => $msg ));
        return $response->send();
    }
public function editAction()
    {
        $this->view->disable();
        $id     = $this->request->getPost('hidden_id');    
        $user   = Users::findFirstById($id);
        $msg    = "";
        if (!$user) {
            $alert = "sukses";
            $msg .= "User was not found";
        }

        if ($this->request->isPost()) {

            $user->assign([
                'name' => $this->request->getPost('name', 'striptags'),
                'profilesId' => $this->request->getPost('profile', 'int'),
                'email' => $this->request->getPost('email', 'email'),
                'banned' => $this->request->getPost('banned'),
                'suspended' => $this->request->getPost('suspended'),
                'active' => $this->request->getPost('active')
            ]);
            
            if (!$user->save()) {
                $alert = "error";
                foreach($user->getMessages() as $message)
                {
                    $msg .= $message ." ";
                }
            } else {
                $alert = "sukses";
                $msg .= "User was updated successfully";
            }
        }

        $response = new \Phalcon\Http\Response();
        $response->setContentType('application/json', 'UTF-8');
        $response->setJsonContent(array('_id' => $this->request->getPost("name"),'alert' => $alert, 'msg' => $msg ));
        return $response->send();
    }
public function editAction ( ) { $ this -> view -> disable ( ) ; $ id = $ this -> request -> getPost ( 'hidden_id' ) ; $ user = Users :: findFirstById ( $ id ) ; $ msg = "" ; if ( ! $ user ) { $ alert = "sukses" ; $ msg .= "User was not found" ; } if ( $ this -> request -> isPost ( ) ) { $ user -> assign ( [ 'name' => $ this -> request -> getPost ( 'name' , 'striptags' ) , 'profilesId' => $ this -> request -> getPost ( 'profile' , 'int' ) , 'email' => $ this -> request -> getPost ( 'email' , 'email' ) , 'banned' => $ this -> request -> getPost ( 'banned' ) , 'suspended' => $ this -> request -> getPost ( 'suspended' ) , 'active' => $ this -> request -> getPost ( 'active' ) ] ) ; if ( ! $ user -> save ( ) ) { $ alert = "error" ; foreach ( $ user -> getMessages ( ) as $ message ) { $ msg .= $ message . " " ; } } else { $ alert = "sukses" ; $ msg .= "User was updated successfully" ; } } $ response = new \ Phalcon \ Http \ Response ( ) ; $ response -> setContentType ( 'application/json' , 'UTF-8' ) ; $ response -> setJsonContent ( array ( '_id' => $ this -> request -> getPost ( "name" ) , 'alert' => $ alert , 'msg' => $ msg ) ) ; return $ response -> send ( ) ; }
Saves the user from the 'edit' action
Saves the user from the edit action