/** * Saves a viaje edited * */ public function saveAction() { if (!$this->request->isPost()) { return $this->dispatcher->forward(array("controller" => "viaje", "action" => "index")); } $viaje_id = $this->request->getPost("viaje_id"); $viaje = Viaje::findFirstByviaje_id($viaje_id); if (!$viaje) { $this->flash->error("viaje does not exist " . $viaje_id); return $this->dispatcher->forward(array("controller" => "viaje", "action" => "index")); } $viaje->setViajeOrigen($this->request->getPost("viaje_origen")); $viaje->setViajeHabilitado(1); if (!$viaje->save()) { foreach ($viaje->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward(array("controller" => "viaje", "action" => "edit", "params" => array($viaje->viaje_id))); } $this->flash->success("El viaje ha sido actualizado correctamente"); return $this->dispatcher->forward(array("controller" => "viaje", "action" => "index")); }