<div class="modal-body">
    <form method="post" name="form_avenant" id="form_avenant" class="bg_form padding_form border_form">
        <div class="row">
            {{ inputAdvance('TEXTAREA', {
                'titre'           : 'Motif de l\'avenant' | trad,
                'name'            : 'motifAvenant',
                'pathValidator'   : path('Ajax.validator.isStringAvecEspace'),
                'paramsValidator' : "{'sizeMin' : '1', 'sizeMax' : '120'}",
            }) }}
        </div>
        <span id="zoneError" style="color:red;"></span>
        <div class="modal-footer">
            <button type="button" class="button secondaire" data-dismiss="modal" onclick="desactivePopup ();">{{ 'Annuler' |trad }}</button>
            <button type="button" class="button principal"  onclick="sendForm('form_avenant');">{{ 'Valider' | trad }}</button>
        </div>
    </form>
</div>

<script>
    function sendForm(nomForm) {
        activeLoader();
	    $.ajax({
			dataType : 'html',
            url: '{{ path('Commande.GestionCommande.ajaxCreateAvenant', {idCommande:idCommande}) }}',
            data:$('#'+ nomForm).serialize(),
            type: "POST",
            statusCode: {
                413: function(xhr) {
                    desactiveLoader();
                    desactivePopup();
                    alert('Error - ModSecurity.');
                }
            },
            success: function(result){
                desactiveLoader();
                desactivePopup();
                $.redirect('{{ path('Commande.ModificationCommande.index', {idCommande:idCommande}) }}');
            },
            error: function(data) {
                $('#zoneError').html(data.responseText);
                desactiveLoader();
            }
        }); 
    }
</script>