infinite-networks/InfiniteFormBundle

[Form] Add "prototype_data" option to polycollection type

Opened this issue · 4 comments

Analogous to: symfony/symfony#12314

Please make it possible to have default data for polycollection prototypes.

merk commented

Which part doesnt work? The prototype should render with whatever default data you render it with in the Symfony application?

Exactly. On the default symfony collection type you can add default values for the prototype of your single type via the prototype_data option. These values are then rendered in the prototype html form fields.

To support this in polycollections, It would need to be possible to set a prototype_data value for each type that can belong to the polycollection. Its not exactly a trivial task to implement unfortunately.

merk commented

I'm not sure I see why this wont already work - the default values will be rendered into the elements by the twig template and be rendered as expected when the prototype is parsed?

Or does the prototype_data not set the value="" attribute on form elements?

Here is a FormType Extension you can use as a workaround:

https://gist.github.com/King2500/fa7c42bcdc017859a52e8009e6605985