This website version is not maintained anymore
Up to date documentation is available in Symfony 3.x website (see the dropdown menu above).
To manage complex collections, we should store the collection's field name prefix somewhere in the view in order to replace descendent prefixes properly. As this is not really natural to get this information from a view, a form theme is delivered with this jquery plugin. It does the job even if your collection has lots of descendent collections.
But this form theme does nothing more than setting plugin options so if you do not want to use it, that's up to you:
name_prefix
is mandatory if you do not use the form theme. It should be the prefix of
all descendant field names. Set this information by using:{{ form.values.vars.full_name }}.
prototype_name
should be the same as inside your form type customization. If you
never given this information, do not set this option (the Symfony2 default value will be used).
allow_add
should have the same value as the option in your form type. It will enable
or disable the ability to add elements in the collection.
allow_remove
should have the same value as the option in your form type. It will enable
or disable the ability to delete elements from the collection.
Value :a
Value :b
Value :c
Code used:
<script type="text/javascript"> /* * Please look at the source code by clicking on the withoutFormTheme.html.twig file above */ $('.form-collection').collection({ prototype_name: '__name__', allow_add: true, allow_remove: true, name_prefix: 'form[values]' }); </script>