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).

JavaScript options: choose the features to enable

Use allowe_up, allow_down, allow_add and allow_remove options to disable some buttons

Warning: if you're using the plugin's form theme, allow_add and allow_remove are taken from your form type configuration.


This demostration is made of the following files (click to see on GitHub in a new tab):
    -     Controller/OptionsController.php
    -     Resources/views/Options/enableButtons.html.twig
    -     Resources/views/Options/options-theme.html.twig
Enable or disable collection's actions :

A simple collection

Add, move, remove values and press Submit.
Value
Value
Value

Value :a

Value :b

Value :c

A collection of themed types

Add, move, remove values and press Submit.

Value :a

Value :b

Value :c


Code used:

    <!-- The name_prefix option is generated, please read at -->

    <script type="text/javascript">

      function reloadCollectionButtons() {
        $('.form-collection').collection({
           name_prefix:  'form[values]',
           allow_up: $('#up').is(':checked'),
           allow_down: $('#down').is(':checked'),
           allow_add: $('#add').is(':checked'),
           allow_remove: $('#remove').is(':checked'),
           allow_duplicate: $('#duplicate').is(':checked')
        });

        $('.advancedForm-collection').collection({
           name_prefix:  'advancedForm[values]',
           allow_up: $('#up').is(':checked'),
           allow_down: $('#down').is(':checked'),
           allow_add: $('#add').is(':checked'),
           allow_remove: $('#remove').is(':checked'),
           allow_duplicate: $('#duplicate').is(':checked')
        });
      }

      reloadCollectionButtons();

      $('.reload-collection').click(function() {
         reloadCollectionButtons();
      });

    </script>