createForm('AppBundle\Form\UserType'); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { //var_dump($user = $this->getUser()->getIdRolInstitucion()->getId()); exit; // $file stores the uploaded PDF file /** @var Symfony\Component\HttpFoundation\File\UploadedFile $file */ $constanciaTrabajo = $form->get('trabajo')->getData(); $constanciaPregrado = $form->get('pregrado')->getData(); // Generate a unique name for the file before saving it $nombreTrabajo = md5(uniqid()).'.'.$constanciaTrabajo->guessExtension(); $nombrePregrado = md5(uniqid()).'.'.$constanciaPregrado->guessExtension(); // Move the file to the directory where brochures are stored $constanciaTrabajo->move( $this->container->getParameter('adscripcion_directory'), $nombreTrabajo ); $constanciaPregrado->move( $this->container->getParameter('adscripcion_directory'), $nombrePregrado ); if($form->get('postgrado')->getData()) { $constanciaPostgrado = $form->get('postgrado')->getData(); $nombrePostgrado = md5(uniqid()).'.'.$constanciaPregrado->guessExtension(); $constanciaPostgrado->move( $this->container->getParameter('adscripcion_directory'), $nombrePostgrado ); } // Update the 'brochure' property to store the PDF file name // instead of its contents $adscripcion->setTrabajo($nombreTrabajo); $adscripcion->setPregrado($nombrePregrado); $adscripcion->setIdRolInstitucion($this->getUser()->getIdRolInstitucion()); $escala->setIdRolInstitucion($this->getUser()->getIdRolInstitucion()); $escala->setFechaEscala($form->get('fecha_oposicion')->getData()); $em = $this->getDoctrine()->getManager(); $em->persist($adscripcion); $em->persist($escala); $em->flush(); //guarda en la base de datos //return $this->redirect($this->generateUrl('app_product_list')); } return $this->render( 'registration/register.html.twig', array('form' => $form->createView()) ); } }