Commit e5c4ad4d8f6217d8e793c6a914e3f458ebba6080
1 parent
53f174811a
Exists in
master
agregado solo las secciones de la oferta para modificar inscripcion
Showing
2 changed files
with
16 additions
and
3 deletions
Show diff stats
src/AppBundle/Controller/InscripcionController.php
| ... | ... | @@ -104,7 +104,7 @@ class InscripcionController extends Controller |
| 104 | 104 | $em = $this->getDoctrine()->getManager(); |
| 105 | 105 | $deleteForm = $this->createDeleteForm($inscripcion); |
| 106 | 106 | $estado_academico = $em->getRepository('AppBundle:EstadoAcademico')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); |
| 107 | - $editForm = $this->createForm('AppBundle\Form\InscripcionEditType', $inscripcion); | |
| 107 | + $editForm = $this->createForm('AppBundle\Form\InscripcionEditType', $inscripcion, array('oferta' => $inscripcion->getIdSeccion()->getOfertaAcademica()->getId())); | |
| 108 | 108 | $editForm->handleRequest($request); |
| 109 | 109 | |
| 110 | 110 | if ($editForm->isSubmitted() && $editForm->isValid()) { | ... | ... |
src/AppBundle/Form/InscripcionEditType.php
| ... | ... | @@ -6,6 +6,7 @@ use Symfony\Component\Form\AbstractType; |
| 6 | 6 | use Symfony\Component\Form\FormBuilderInterface; |
| 7 | 7 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 8 | 8 | use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
| 9 | +use Doctrine\ORM\EntityRepository; | |
| 9 | 10 | |
| 10 | 11 | class InscripcionEditType extends AbstractType |
| 11 | 12 | { |
| ... | ... | @@ -15,8 +16,19 @@ class InscripcionEditType extends AbstractType |
| 15 | 16 | */ |
| 16 | 17 | public function buildForm(FormBuilderInterface $builder, array $options) |
| 17 | 18 | { |
| 19 | + $this->oferta = $options['oferta']; | |
| 18 | 20 | $builder |
| 19 | - ->add('idSeccion') | |
| 21 | + ->add('idSeccion', EntityType::class, array( | |
| 22 | + 'class' => 'AppBundle:Seccion', | |
| 23 | + 'query_builder' => function (EntityRepository $er){ | |
| 24 | + return $er->createQueryBuilder('u') | |
| 25 | + ->where('u.ofertaAcademica = ?1') | |
| 26 | + ->setParameters(array( | |
| 27 | + 1 => $this->oferta | |
| 28 | + )); | |
| 29 | + | |
| 30 | + }, | |
| 31 | + )) | |
| 20 | 32 | ->add('idEstatus') |
| 21 | 33 | |
| 22 | 34 | ; |
| ... | ... | @@ -28,7 +40,8 @@ class InscripcionEditType extends AbstractType |
| 28 | 40 | public function configureOptions(OptionsResolver $resolver) |
| 29 | 41 | { |
| 30 | 42 | $resolver->setDefaults(array( |
| 31 | - 'data_class' => 'AppBundle\Entity\Inscripcion', | |
| 43 | + 'data_class' => 'AppBundle\Entity\Inscripcion', | |
| 44 | + 'oferta' => null | |
| 32 | 45 | )); |
| 33 | 46 | } |
| 34 | 47 | } | ... | ... |