/** * Allows a user to edit a workshop category * */ public function editAction() { $messages = array(); $get = Zend_Registry::get('getFilter'); if (!isset($get->categoryId)) { throw new Ot_Exception_Input('msg-error-categoryIdNotSet'); } $category = new Category(); $thisCategory = $category->find($get->categoryId); if (is_null($thisCategory)) { throw new Ot_Exception_Data('msg-error-category'); } $form = $category->form($thisCategory->toArray()); if ($this->_request->isPost()) { if ($form->isValid($_POST)) { $data = array('categoryId' => $form->getValue('categoryId'), 'name' => $form->getValue('name'), 'description' => $form->getValue('description')); $category->update($data, null); $trigger = new Ot_Trigger(); $data['accountId'] = Zend_Auth::getInstance()->getIdentity()->accountId; $trigger->setVariables($data); $trigger->dispatch('Category_Edit'); $this->_helper->flashMessenger->addMessage('msg-info-categoryModified'); $this->_helper->redirector->gotoUrl('/workshop/category/details/?categoryId=' . $form->getValue('categoryId')); } else { $messages[] = "msg-error-formSubmitProblem"; } } $this->view->messages = $messages; $this->view->form = $form; $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.wysiwyg.js'); $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.wysiwyg.css'); $this->_helper->pageTitle('workshop-category-edit:title'); }