Guest User

Untitled

a guest
May 29th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1.  public function editAction() {
  2.         // action body
  3.         $this->view->title = "Edit User";
  4.         $this->view->headTitle($this->view->title, 'PREPEND');
  5.         $form = new Application_Form_Admin();
  6.         $form->submit->setLabel('Save');
  7.         $this->view->form = $form;
  8.         if ($this->getRequest()->isPost()) {
  9.             $formData = $this->getRequest()->getPost();
  10.             if ($form->isValid($formData)) {
  11.                 $id = (int) $form->getValue('id');
  12.                 $username = $form->getValue('username');
  13.                 $password = $form->getValue('password');
  14.                 $real_name = $form->getValue('real_name');
  15.                 $admin = $form->getValue('admin');
  16.                 $users = new Application_Model_DbTable_Users();
  17.                 $users->updateUser($id, $username, $password, $real_name, $admin);
  18.                 $this->_helper->redirector('index');
  19.             } else {
  20.                 $form->populate($formData);
  21.             }
  22.         } else {
  23.             $id = $this->_getParam('id', 0);
  24.             if ($id > 0) {
  25.                 $users = new Application_Model_DbTable_Users();
  26.                 $form->populate($users->getUser($id)->toArray());
  27.             }
  28.         }
  29.     }
Add Comment
Please, Sign In to add comment