public function editAction()
 {
     $id = $this->_getParam('id', null);
     $announcement = Engine_Api::_()->getItem('announcement', $id);
     $this->view->form = $form = new Announcement_Form_Admin_Edit();
     $form->populate($announcement->toArray());
     // Save values
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $params = $form->getValues();
         $announcement->setFromArray($params);
         $announcement->save();
         return $this->_helper->redirector->gotoRoute(array('action' => 'index'));
     }
 }
示例#2
0
 public function editAction()
 {
     $this->view->form = $form = new Announcement_Form_Admin_Edit();
     $id = $this->_getParam('id', null);
     $announcement = Engine_Api::_()->getItem('announcement', $id);
     // Save values
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $params = $form->getValues();
         //$params['user_id'] = $this->_helper->api()->user()->getViewer()->getIdentity();
         //$announcement = $this->_helper->api()->getDbtable('announcements', 'announcement')->createRow();
         $announcement->setFromArray($params);
         $announcement->save();
         $this->_helper->redirector->gotoRoute(array('action' => 'index'));
         //$form->addMessage('Changes Saved!');
     } else {
         $form->populate($announcement->toArray());
     }
 }