symfony/symfony — Issue #3503: Initial data for prototype and allow_add feature
Author: Moinax
Created: 2012-03-05 11:34:06+00:00
State: open

Hello,

Is there a way to provide initial data to generate the right form prototype when we embed a collection ?

For example, we have a form for an entity Page which embed a collection of ImageFormType (with prototype and allow_add).

The ImageFormType itself has a collection of TranslationType.

As we know we will have 4 translations, we don't want to use prototype and allow_add on this collection, but prepopulate the collection with 4 new entity instances.

But the prototype doesn't use any initial data to generate the html, so the Translation collection is empty.

We found a way to manage this by adding an "initial_data" in an extension of the prototype generator, but we still need to add the prototype and allow_add option on the Translation collection to make it works, which is not what we want as there should be only 4 translations.

Isn't it an issue that we are forced to use the "allow_add" to be sure the Resizer is called and generates the right collection fields ?