Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\HttpFoundation\Request;
- use AppBundle\Entity\Reclamation;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use Symfony\Component\Form\Extension\Core\Type\IntegerType;
- use Symfony\Component\Form\Extension\Core\Type\TextareaType;
- use Symfony\Component\Form\Extension\Core\Type\SubmitType;
- use Symfony\Bridge\Doctrine\Form\Type\EntityType;
- use AppBundle\Form\Type\CategorieType;
- use AppBundle\Form\Type\RapporteurType;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- class ReclamationController extends Controller
- {
- /**
- * @Route("Reclamation/Modifier/{id}")
- */
- public function ModifierReclamationAction(Request $request, Reclamation $reclamation)
- {
- $form = $this->createFormBuilder($reclamation)
- ->add('libelle', TextType::class, array('label' => 'Libellé : '))
- ->add('description', TextType::class, array('label' => 'Description : '))
- ->add('priorite', ChoiceType::Class, array(
- 'choices' => array(
- 'basse' => 'basse',
- 'normale' => 'normale',
- 'élevée' => 'élevée',
- ),
- 'choices_as_values' => true,
- ))
- ->add('id_categorie', EntityType::class, array(
- 'label' => 'Categorie : ',
- 'class' => 'ExamenTunivisionCultureBundle:Evenement',
- 'placeholder' => 'Sélectionner une Categorie',
- // 'choice_label' => 'nom'
- 'choice_label' => function($id_categorie) {
- return $id_categorie->getTitre();
- }
- ))
- ->add('id_rapporteur', EntityType::class, array(
- 'label' => 'rapporteur : ',
- 'class' => 'AppBundle:Rapporteur',
- 'placeholder' => 'Sélectionner un rapporteur',
- // 'choice_label' => 'nom'
- 'choice_label' => function($id_rapporteur) {
- return $id_rapporteur->getId();
- }
- ))
- ->add('save', SubmitType::class, array('label' => 'Enregistrer'))
- ->getForm();
- $form->handleRequest($request);
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $em->persist($form->getData());
- $em->flush();
- }
- return $this->render('AppBundle:Reclamation:ModifierReclamation.html.twig', array(
- 'myform' => $form->createView()
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement