<div class="modal fade" id="modaldocument" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                </br>
            </div>

            <div class="modal-body">
                <h3 class="panel-title">{{ 'changeName' | trans }}</h3>

                <form id="updateName" enctype="multipart/form-data" method="post" action="{{ path('ujm_question_name_update') }}">

                    <p>{{ 'newName' | trans }} ?</p>
                    <input class="form-control" type="text" id='newlabel' name='newlabel' required="true"/>

                    <div class="modal-footer">
                        <input id="updateSubmit" type="submit" value="{{ 'change' | trans }} !"
                            onclick="ValidName('{{ 'wrongName' | trans }}','newlabel', '{{ path('ujm_Document_name_alreadyExist') }}', '{{ 'alreadyExist' | trans }}', 'updateName');
                                return false;" class="btn btn-primary"/>

                        <input type="hidden" id="oldName" name="oldName" value="{{oldDocLabel}}"/>
                        <input type="hidden" id="i" name="i" value="{{i}}"/>
                    </div>
                </form>
           </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('#modaldocument').modal('toggle', 'show');

    var oldname = $('#oldName').val();
    var i = $('#i').val();

    $(document).ready(function () {

        $('#newlabel').val(oldname);

        var options = {
            success: function (data) {
                if ($('#docLabel' + i).html().trim() == oldname) {
                    $('#docLabel' + i).html(data);
                    $('#modaldocument').modal('hide');
                    return false;
                }
            },
            error: function () {
                alert('Veuillez actualiser la page ...');
            }
        };

        $("#updateName").ajaxForm(options);
    });
</script>