/** Edit a reference entity
  * @todo move the update function to model
  */
 public function editAction()
 {
     $form = new ReferenceFindForm();
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $updateData = array();
             $updateData['pages_plates'] = $form->getValue('pages_plates');
             $updateData['reference'] = $form->getValue('reference');
             $updateData['updated'] = $this->getTimeForForms();
             $updateData['updatedBy'] = $this->getIdentityForForms();
             foreach ($updateData as $key => $value) {
                 if (is_null($value) || $value == "") {
                     unset($updateDataData[$key]);
                 }
             }
             $where = array();
             $bibs = new Bibliography();
             $where = $bibs->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
             $update = $bibs->update($updateData, $where);
             $findID = $this->_getParam('findID');
             $this->_flashMessenger->addMessage('Reference details updated!');
             $this->_redirect(self::REDIRECT . $findID);
         } else {
             $form->populate($formData);
         }
     } else {
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $bibs = new Bibliography();
             $bib = $bibs->fetchFindBook($id);
             $form->populate($bib['0']);
         }
     }
 }
예제 #2
0
 /** Edit a reference entity
  * @access public
  * @return void
  */
 public function editAction()
 {
     $form = new ReferenceFindForm();
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             unset($formData['authors']);
             unset($formData['submit']);
             $where = array();
             $where[] = $this->_bibliography->getAdapter()->quoteInto('id = ?', $this->getParam('id'));
             $this->_bibliography->update($formData, $where);
             $this->getFlash()->addMessage('Reference details updated!');
             $this->redirect($this->getRedirect() . 'record/id/' . $this->getParam('findID'));
         } else {
             $form->populate($this->_request->getPost());
         }
     } else {
         $id = (int) $this->_request->getParam('id', 0);
         if ($id > 0) {
             $bib = $this->_bibliography->fetchFindBook($id, $this->getController());
             $form->populate($bib['0']);
             $pubs = new Publications();
             $titles = $pubs->getTitlesPairs($bib[0]['authors']);
             $form->pubID->addMultiOptions($titles);
             $form->pubID->setValue($bib[0]['pubID']);
         }
     }
 }