Is it possible to create and render and array of forms I know about collections but they don't really fit in my idea?
What I want is something like this
$data=$em->findAll();
$Forms=$this->createForm(new SomeType,$data);
return $this->render(someView,array("Forms"=>$Forms->createView()));
{% for Form in Forms %}
{{ form(Form)}}
{% endfor %}
Just create your forms in array:
$data = $em->findAll();
for ($i = 0; $i < $n; $i++) {
$forms[] = $this->container
->get('form.factory')
->createNamedBuilder('form_'.$i, new SomeType, $data)
->getForm()
->createView();
}
return $this->render(someView, array("forms" => $forms));
As mentioned by edlouth you can create each form named separately. I updated my code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With