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 : hide Up and Down buttons on useless elements

Use hide_useless_buttons option to display or not the up button on the first item, and the down button on the last one.

This can be useful if you want to style useless buttons by yourself, instead of display:none.

Test it live:

This demostration is made of the following files (click to see on GitHub in a new tab):
    -     Controller/OptionsController.php
    -     Resources/views/Options/hideMoveUpDown.html.twig
    -     Resources/views/Options/options-theme.html.twig
Add, move, remove values and press Submit.

Value :a

Value :b

Value :c

Code used:

    <script type="text/javascript">

            hide_useless_buttons: false

        $('#test-it').on('click', function() {

            // only useful for the demo
            $('.collection-up, .collection-down').css('display', '');

                hide_useless_buttons: $('#test-it').is(':checked')