public function viewAction()
 {
     $submission = null;
     $form = new LeadForm();
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         $message = "No Lead ID could be found.";
         $this->errorResponse->addMessage($message, "error");
         return $this->redirect()->toRoute('home', array('action' => 'index'), array('query' => array('msg' => 1)));
     }
     // Get the Lead with the specified id. An exception is thrown
     // if it cannot be found, in which case go to the index page.
     try {
         $submission = $this->getSubmissionMapper()->getSubmission($id);
     } catch (\Exception $ex) {
         $message = "Lead Entry could not be retrieved.";
         $this->errorResponse->addMessage($message, "error");
         return $this->redirect()->toRoute('home', array('action' => 'index'), array('query' => array('msg' => 1)));
     }
     if ($submission && $submission instanceof SubmissionEntity) {
         if (!$submission->getLead()) {
             $message = "A Lead could not be found with the ID: \"{$id}\". Return to <a href=\"javascript:history.back()\" class=\"alert-link\">previous page</a>?";
             $this->errorResponse->addMessage($message, "error");
         }
         $form->bind($submission);
         $form->get('lead')->get('timecreated')->setOptions(array('format' => 'F d, Y H:i:s'));
         $form->get('lead')->get('timesubmitted')->setOptions(array('format' => 'F d, Y H:i:s'));
         $form->remove('submit');
     } else {
         $message = "A Lead could not be found with the ID: \"{$id}\". Return to <a href=\"javascript:history.back()\" class=\"alert-link\">previous page</a>?";
         $this->errorResponse->addMessage($message, "error");
     }
     return new ViewModel(array('submission' => $submission, 'form' => $form));
 }