/** Edit coin data
  * @throws Pas_Exception_Param
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $finds = new Finds();
         $this->view->finds = $finds->getFindNumbersEtc($this->_getParam('returnID'));
         $broadperiod = (string) $this->_getParam('broadperiod');
         $form = $this->_helper->coinFormLoader($broadperiod);
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $updateData = $form->getValues();
                 $oldData = $this->_coins->fetchRow('id=' . $this->_getParam('id'))->toArray();
                 $where = $this->_coins->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 //Update the coins table
                 $update = $this->_coins->update($updateData, $where);
                 //Audit the changes
                 $this->_helper->audit($updateData, $oldData, 'CoinsAudit', $this->_getParam('id'), $this->_getParam('returnID'));
                 //Update solr index
                 $this->_helper->solrUpdater->update('beowulf', $this->_getParam('returnID'));
                 $this->_helper->flashMessenger->addMessage('Numismatic details updated.');
                 $this->_redirect(self::REDIRECT . 'record/id/' . $this->_getParam('returnID'));
             } else {
                 $form->populate($form->getValues());
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_getParam('id', 0);
             if ($id > 0) {
                 $coin = $this->_coins->getCoinToEdit($id);
                 $form->populate($coin['0']);
                 $formLoader = $this->_helper->coinFormLoaderOptions($broadperiod, $coin);
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
 /** Edit jetton data
  * @todo rewrite for audit etc
  */
 public function editAction()
 {
     if ($this->_getParam('id', false)) {
         $finds = new Finds();
         $this->view->finds = $finds->getFindNumbersEtc($this->_getParam('returnID'));
         $broadperiod = (string) $this->_getParam('broadperiod');
         switch ($broadperiod) {
             case 'MEDIEVAL':
                 $form = new TokenJettonForm();
                 $form->details->setLegend('Edit Medieval jetton data');
                 $form->submit->setLabel('Save data');
                 $this->view->headTitle('Edit a Medieval jetton\'s details');
                 break;
             case 'POST MEDIEVAL':
                 $form = new TokenJettonForm();
                 $form->details->setLegend('Edit Post Medieval jetton data');
                 $form->submit->setLabel('Save data');
                 $this->view->headTitle('Edit a Post Medieval jetton\'s details');
                 break;
             default:
                 throw new Exception('You cannot have a jetton for that period.');
                 break;
         }
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
             if ($form->isValid($form->getValues())) {
                 $updateData = $form->getValues();
                 $oldData = $this->_coins->fetchRow('id=' . $this->_getParam('id'))->toArray();
                 $where = $this->_coins->getAdapter()->quoteInto('id = ?', $this->_getParam('id'));
                 $update = $this->_coins->update($updateData, $where);
                 $this->_helper->audit($updateData, $oldData, 'CoinsAudit', $this->_getParam('id'), $this->_getParam('returnID'));
                 $this->_flashMessenger->addMessage('Numismatic details updated.');
                 $this->_redirect(self::REDIRECT . 'record/id/' . $this->_getParam('returnID'));
                 $this->_helper->solrUpdater->update('beowulf', $this->_getParam('returnID'));
             } else {
                 $this->_flashMessenger->addMessage('Please check your form for errors');
                 $form->populate($_POST);
             }
         } else {
             // find id is expected in $params['id']
             $id = (int) $this->_getParam('id', 0);
             if (is_int($id)) {
                 $coin = $this->_coins->fetchRow('id=' . $this->_getParam('id'))->toArray();
                 $form->populate($coin);
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }