Esempio n. 1
0
 public function edit()
 {
     if (!isset($this->currentUser)) {
         throw new Exception("Not in session. Editar premio requiere loguearse");
     }
     $premioNombre = $_REQUEST["nombrePremio"];
     $premio = $this->premioMapper->findByName($premioNombre);
     if ($premio == NULL) {
         throw new Exception("Ningun premio con el nombre \"" . $premioNombre . "\"");
     }
     if (isset($_POST["submit"])) {
         // reaching via HTTP Post...
         $premio = new Premio();
         $premio->setImportePopular($_POST["importePopular"]);
         $premio->setImporteProfesional($_POST["importeProfesional"]);
         $premio->setFechaPremio($_POST["fechaPremio"]);
         $premio->setPatrocinador_idPatrocinador($_POST["patrocinador_idPatrocinador"]);
         $premio->setNombrePremio($_POST["nombrePremio"]);
         $premio->setIdPremio($_POST["idPremio"]);
         //print_r($premio);
         //die();
         try {
             $premio->checkIsValidForUpdate();
             // if it fails, ValidationException
             $this->premioMapper->update($premio);
             $this->view->redirect("premio", "listar");
         } catch (ValidationException $ex) {
             $errors = $ex->getErrors();
             $this->view->setVariable("errors", $errors);
         }
     }
     $this->view->setVariable("premio", $premio);
     $this->view->render("premios", "edit");
 }