infinite-networks / InfiniteFormBundle

A collection of useful form types and extensions for Symfony.
169 stars 40 forks source link

[Form] Add "prototype_data" option to polycollection type #53

Open ghost opened 8 years ago

ghost commented 8 years ago

Analogous to: https://github.com/symfony/symfony/pull/12314

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

merk commented 8 years ago

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

ghost commented 8 years ago

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 8 years ago

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?

King2500 commented 8 years ago

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

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