This website version is not maintained anymore
Up to date documentation is available in Symfony 3.x website (see the dropdown menu above).
Use min
and max
options to define limits on the number of elements in the collection.
The example below shows you a collection having from 2 to 5 elements.
Add button will disappear if your collection has 5 elements, and Remove button if your collection has 2 elements.
Value :a
Value :b
Value :c
On a themed type, elements having collection-add
class will be hidden if your collection has 5 elements, and elements
having collection-remove
class if your collection has 2 elements.
Value :a
Value :b
Value :c
Code used:
<script type="text/javascript"> $('.form-collection, .advancedForm-collection').collection({ min: 2, max: 5 }); </script>