public function userAction() { $this->userService->checkRightGate('USER_ADMIN'); $form = $this->getForm('userEditForm', dirname(__FILE__) . '/userAdminForm.xml'); $form->addDataProvider('listRoles', $this->userService->listRoles()); if ($form->isSubmit()) { if ($form->isValid()) { $user = $form->getContainer('user'); $this->userService->saveUserWithRoles($user); $this->forward('user', 'admin', 'list'); return; } } else { $id = $this->getParam('id', 0); if ($id == '') { throw new \org\equinox\exception\ParameterInvalidException("No (id) provided then editing a user !!!"); } $user = $this->userService->getUserWithRoles($id); if ($user == null) { throw new \org\equinox\exception\ParameterInvalidException("No user found for id ({$id})"); } $form->setContainer('user', $user); } $this->storeForm($form); $this->assign('form', $form); }
public function editAction() { $form = $this->formManager->initForm('userEditForm', dirname(__FILE__) . '/userForm.xml'); $form->setUnicityValidator('user', $this->userDao); $new = false; if ($form->isSubmit()) { if ($form->isValid()) { $user = $form->getContainer('user'); $this->userService->save($user); $this->goHome(); return; } } else { if ($this->userProfil->isConnected()) { $user = clone $this->userProfil->getCurrentUser(); // if not cloned, we edit directly the currentuser } else { $user = new \org\equinox\modules\user\dao\UserDto(); $new = true; } $form->setContainer('user', $user); } // Mandatory : this store the original object in session to retrieve after update by the form $this->formManager->storeForm($form); $this->assign('definition', $form); $this->assign('form', $form); $this->assign('new', $new); }