Yellow Flag

This website version is not maintained anymore

Up to date documentation is available in Symfony 3.x website (see the dropdown menu above).

Advanced usage: Collection of form collections

On the most advanced forms, this is possible to see collection of form collections (for example if the form helps to create forms dynamically).

In fact, that's easier to explain if you look at the sample displayed at the bottom of this page.


This demostration is made of the following files (click to see on GitHub in a new tab):
    -     Controller/AdvancedController.php
    -     Resources/views/Advanced/collectionOfCollections.html.twig

Collection 1:

a

b

c

Collection 2:

d

e

f

Collection 3:

g

h

i


Code used:

    <script type="text/javascript">

        $('.parent-collection').collection({
            min: 0,
            max: 5,
            up: '<a href="#" class="btn btn-default"><span class="glyphicon glyphicon-arrow-up"></span> Move collection up</a>',
            down: '<a href="#" class="btn btn-default"><span class="glyphicon glyphicon-arrow-down"></span> Move collection down</a>',
            add: '<a href="#" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add collection</a>',
            remove: '<a href="#" class="btn btn-default"><span class="glyphicon glyphicon-trash"></span> Remove collection</a>',
            duplicate: '<a href="#" class="btn btn-default"><span class="glyphicon glyphicon-th-large"></span> Duplicate collection</a>',
            prefix: 'parent',
            allow_duplicate: true,
            children: [{
                selector: '.child-collection',
                add: '<a href="#" class="btn btn-default">Add</span></a>',
                allow_duplicate: true
            }]
        });

    </script>