Cristhian Boujon
Cristhian Boujon

Reputation: 4190

Adding dynamic fields in a form with Symfony 2

Let's say that the entity Foo has many entities Bar. In views/Foo/new.html I want to create many entities Bar in the same form, allowing to the user add many groups of HTML fields each time that the user clicks on a button "Add". When the user submits the form, I want to create all entities and the new Foo related with all Bars.

What is the best approach to do it in Symfony2?

Upvotes: 0

Views: 73

Answers (1)

dmnptr
dmnptr

Reputation: 4304

You can do that with the embedded collection of forms. There is pretty good documentation about that at Symfony's website - http://symfony.com/doc/current/cookbook/form/form_collections.html

Upvotes: 1

Related Questions