/** * Creates a new viaje */ public function createAction() { if (!$this->request->isPost()) { return $this->dispatcher->forward(array("controller" => "viaje", "action" => "index")); } $viaje = new Viaje(); $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" => "new")); } $this->flash->success("El viaje ha sido creado correctamente"); return $this->dispatcher->forward(array("controller" => "viaje", "action" => "index")); }