public function transformContent() { // get current permission id $permissionId = $this->getRequest()->getParameter('permissionid'); // initialize the form $form = $this->getForm('PermissionEdit'); $permissionIdControl = $form->getFormElementByName('permissionid'); $permissionIdControl->setAttribute('value', $permissionId); $displayName = $form->getFormElementByName('DisplayName'); $name = $form->getFormElementByName('Name'); $value = $form->getFormElementByName('Value'); $uM = $this->getManager(); if ($form->isSent()) { if ($form->isValid()) { $permission = new UmgtPermission(); $permission->setObjectId($permissionId); $permission->setDisplayName($displayName->getValue()); $permission->setName($name->getValue()); $permission->setValue($value->getValue()); $uM->savePermission($permission); $this->getResponse()->forward($this->generateLink(['mainview' => 'permission', 'permissionview' => '', 'permissionid' => ''])); } else { $form->transformOnPlace(); } } else { $permission = $uM->loadPermissionByID($permissionId); $displayName->setAttribute('value', $permission->getDisplayName()); $name->setAttribute('value', $permission->getName()); $value->setAttribute('value', $permission->getValue()); $form->transformOnPlace(); } }
public function transformContent() { $uM = $this->getManager(); $form = $this->getForm('PermissionAdd'); if ($form->isSent() && $form->isValid()) { $displayName = $form->getFormElementByName('DisplayName'); $name = $form->getFormElementByName('Name'); $value = $form->getFormElementByName('Value'); $permission = new UmgtPermission(); $permission->setDisplayName($displayName->getValue()); $permission->setName($name->getValue()); $permission->setValue($value->getValue()); $uM->savePermission($permission); $this->getResponse()->forward($this->generateLink(['mainview' => 'permission', 'permissionview' => ''])); } $form->transformOnPlace(); }