public function add($value, array &$invalid) { $form = new Logic_Branch_Form_Generic(); $logic = new Logic_Branch(); if ($value['web_name'] == null) { $value['web_name'] = str_replace(" ", "", $value['symbol_def']); } $form->setDefaults($value); if ($form->isValidPartial($value)) { $logic->createBranch($form); } else { echo $form->getElement('branch_name')->getValue(); $invalid[] = $value; } }
public function editAction() { $request = $this->getRequest(); $id = $request->getParam('id'); $idHash = $id; $id = $this->_helper->IdConvert->hexToStr($id); $logic = new Logic_Branch(); $data = array(); try { $data = $logic->showBranch($id); } catch (Logic_Branch_Exception $e) { $this->_helper->messenger->error(); $this->_helper->redirector('index'); return; } $form = new Logic_Branch_Form_Generic(array('id' => $id, 'idHash' => $idHash, 'map_image' => $data['map_image'])); if ($request->isPost()) { if ($form->isCancelled($this->getRequest()->getPost())) { $this->_helper->redirector('show', null, null, array('id' => $request->getParam('id'))); return; } if ($form->isValid($request->getPost())) { try { $logic->updateBranch($form, $id); $this->_helper->messenger->success(); $this->_helper->redirector('index'); return; } catch (Logic_Branch_Exception $e) { $this->_helper->messenger->error(); } } } else { $branchgroups_select = $logic->getGroupsForBranch($id); $db = Zend_Db_Table::getDefaultAdapter(); $branchgroups = $db->fetchAll($branchgroups_select); $tmp = array(); foreach ($branchgroups as $group) { $tmp[] = $group['id']; } $defaults = $data->toArray(); $defaults['groups'] = $tmp; $form->setDefaults($defaults); } $this->view->form = $form; }