Example #1
0
 public function edit()
 {
     $rawAttributeGroupData = $this->model->getGroup($this->id);
     if (empty($rawAttributeGroupData)) {
         App::redirect(__ADMINPANE__ . '/attributegroup/');
     }
     $this->registry->xajaxInterface->registerFunction(array('AddGroup', $this->model, 'addEmptyGroup'));
     $this->registry->xajaxInterface->registerFunction(array('DeleteGroup', $this->model, 'deleteGroup'));
     $populateData = array('group_data' => array('attributegroupname' => $rawAttributeGroupData['name'], 'category' => $rawAttributeGroupData['category']), 'attribute_data' => array('attributes' => $rawAttributeGroupData['attributes']));
     $error = Session::getVolatileErrorMessage();
     if ($error) {
         $this->registry->template->assign('errormessage', print_r($error, 1));
     }
     $this->formModel->setPopulateData($populateData);
     $form = $this->formModel->initForm();
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         try {
             $this->model->editAttributeGroup($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id);
         } catch (Exception $e) {
             $this->registry->template->assign('error', $e->getMessage());
         }
         App::redirect(__ADMINPANE__ . '/attributegroup/edit/' . $this->id);
     }
     $this->renderLayout(array('form' => $form->Render(), 'existingGroups' => $this->model->getAllAttributeGroupName(), 'currentGroup' => $rawAttributeGroupData));
 }