<div class="contenu clearfix">
    <H1>{{ 'Rubriques' | trad }}</H1>
    {{ ariane() }}

    <h3>
        {{ rubrique? 'Modification d\'une rubrique'| trad :'Création d\'une rubrique' | trad }}
        <button type="button" class="principal button last " id="rubrique_form_create">
            {{ 'Valider' | trad }}
        </button>
        <a href="{{ path('Stock.Rubrique.gestion') }}" class="secondaire button">
            {{  'Annuler' | trad }}
        </a>
    </h3>

    <div class="tab-content clearfix" id="tab-content">
        <div class="tab-content" style="margin-top:10px;">
            <div class="tab-pane active in clearfix padding_form bg_form border_form">
                <form method="post" name="srubcomp" id="rubrique_form" action="{{ action }}">
                    <div class="row">
                        <div class="colonne2">
                            {{ inputAdvance('TEXT', {
                                'titre' : 'Code' | trad,
                                'name'  : 'SRUBCOMP[CODE]',
                                'value' : rubrique ? rubrique.CODE: '',
                                'pathValidator' : path('Ajax.validator.isCode'),
                                'paramsValidator' : "{'sizeMin' : '0', 'sizeMax' : '30'}",
                                'option': rubrique is defined ? 'readonly': ''
                            }) }}
                        </div>
                        <div class="colonne2 last">
                            {{ inputAdvance('TEXT', {
                                'titre' : 'Libellé' | trad,
                                'name'  : 'SRUBCOMP[LIBELLE]',
                                'value' : rubrique ? rubrique.LIBELLE: '',
                                'pathValidator' : path('Ajax.validator.isStringAvecEspace'),
                                'paramsValidator' : "{'sizeMin' : '0', 'sizeMax' : '255'}",
                                'obligatoire': true,
                            }) }}
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="application/javascript" src="{{ baseUrl('js/Modules/Stock/enteForm.js') }}"></script>
<script type="application/javascript" src="{{ baseUrl('js/Modules/Stock/postAjaxForm.js') }}"></script>
<script type="application/javascript">
    $('#rubrique_form_create').on('click', (event) => {
        event.preventDefault();

        activeLoader();
        const form = $('#rubrique_form');
        const formData = form.serializeArray();

        submitForm(form, formData);
    });
</script>