From 1ea54c39b32975c2769f9e8d47bd6474d337b4df Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sat, 8 Nov 2014 16:59:36 +0100 Subject: [PATCH] Choice of the Form --- Controller/ReportController.php | 24 +++++++++++++++++++++++- Resources/views/Report/index.html.twig | 16 ++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 26e0f54b9..2e3b068ef 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -19,16 +19,38 @@ class ReportController extends Controller * Lists all Report entities. * */ - public function indexAction() + public function indexAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entities = $em->getRepository('ChillReportBundle:Report')->findAll(); + $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findByEntity('Chill\ReportBundle\Entity\Report'); + + $cFGroupsChoice = array(); + + foreach ($cFGroups as $g) { + $cFGroupsChoice[$g->getId()] = $g->getName($request->getLocale()); + } + + $form = $this->get('form.factory') + ->createNamedBuilder(null, 'form', null, array( + 'method' => 'GET', + 'action' => $this->generateUrl('report_new'), + 'csrf_protection' => false + )) + ->add('type', 'choice', array( + 'choices' => $cFGroupsChoice + )) + ->getForm(); + return $this->render('ChillReportBundle:Report:index.html.twig', array( 'entities' => $entities, + 'form' => $form->createView() )); } + /** * Creates a new Report entity. * diff --git a/Resources/views/Report/index.html.twig b/Resources/views/Report/index.html.twig index 7cc7549f1..c021d8dbc 100644 --- a/Resources/views/Report/index.html.twig +++ b/Resources/views/Report/index.html.twig @@ -41,11 +41,11 @@ - - {% endblock %} + + {{ form_start(form) }} + {{ form_row(form) }} + + {{ form_end(form) }} +{% endblock %}