示例#1
0
 public function editAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $id = $this->_getParam('id', 0);
     $form = new Admin_Form_Role($id);
     if (!empty($id)) {
         $obj = new Application_Entity_RunSql('Role');
         $obj->getone = $id;
         $dataObj = $obj->getone;
         $form->populate($dataObj);
     }
     $this->view->titulo = "Editar Rol";
     $this->view->submit = "Guardar cambios";
     $this->view->action = "/admin/role/new";
     $form->setDecorators(array(array('ViewScript', array('viewScript' => 'forms/_formRole.phtml'))));
     echo $form;
 }
示例#2
0
 public function updateAction()
 {
     $roleForm = new Admin_Form_Role();
     $roleForm->setAction('/admin/role/update')->setMethod('post');
     if ($this->_request->isPost()) {
         if ($roleForm->isValid($_POST)) {
             $roleData = $roleForm->getValues();
             $roleModel = new Admin_Model_Role();
             $roleModel->updateRole($roleData['role_id'], $roleData['role_name'], $roleData['description']);
             $this->_redirect('/admin/role/list');
         }
     } else {
         $roleModel = new Admin_Model_Role();
         $id = $this->_request->getParam('id');
         $roleRow = $roleModel->find($id)->current();
         $roleForm->populate($roleRow->toArray());
     }
     $this->view->form = $roleForm;
 }