mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Choice of the Form
This commit is contained in:
parent
005e56c72a
commit
1ea54c39b3
@ -19,16 +19,38 @@ class ReportController extends Controller
|
|||||||
* Lists all Report entities.
|
* Lists all Report entities.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction(Request $request)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$entities = $em->getRepository('ChillReportBundle:Report')->findAll();
|
$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(
|
return $this->render('ChillReportBundle:Report:index.html.twig', array(
|
||||||
'entities' => $entities,
|
'entities' => $entities,
|
||||||
|
'form' => $form->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Report entity.
|
* Creates a new Report entity.
|
||||||
*
|
*
|
||||||
|
@ -41,11 +41,11 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>
|
{{ form_start(form) }}
|
||||||
<a href="{{ path('report_new') }}">
|
{{ form_row(form) }}
|
||||||
Create a new entry
|
<button type="submit">
|
||||||
</a>
|
Create a new report
|
||||||
</li>
|
</button>
|
||||||
</ul>
|
{{ form_end(form) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user