This website version is not maintained anymore
Up to date documentation is available in Symfony 3.x website (see the dropdown menu above).
In the Basic Usage example, we defined the collection's selector in the form type, but that's not a good practice, as a selector should take part of the view.
You can reference your form collection using any container, such as a <div>
, and setting
data-collection="{{ form.collectionField.vars.id }}"
.
Value :a
Value :b
Value :c
Code used:
<!-- Note that data-collection="(...)" was generated by the form component, I useddata-collection="{{ form.values.vars.id }}" --> <div class="i-am-a-collection" data-collection="form_values"></div> <script type="text/javascript"> $('.i-am-a-collection').collection(); </script>