templates/front/theme1/form/form.html.twig line 1

Open in your IDE?
  1. {% import "front/"~ app.request.server.get('APP_THEME') ~"/form/macro_form.html.twig" as forms %}
    {% set parametre = ParametreSite() %}
    
    {% if bloc.form %}
    <section class="form-bloc">
        <div class="container-fluid wrapper">
        <form  id="form-{{bloc.form.id}}" action="{{path('save_form')}}" method="post" enctype="multipart/form-data" class="needs-validation form-recap {{bloc.form.identifier}}" novalidate>
    
            {% for message in app.flashes('success-form-' ~ bloc.form.id) %}
                <div class="alert alert-success alert-form mx-auto text-center">
                    {{ message|raw }}
                </div>
            {% endfor %}
    
            {% for message in app.flashes('error-form-' ~ bloc.form.id) %}
                <div class="alert alert-danger">
                    {{ message|raw }}
                </div>
            {% endfor %}
            
            {% set message = 'validation_form'|trans([],'variable') %}
            <input type="hidden" value="{{bloc.form.id}}" name="IdForm">
            <div class="row">
                {% for item in bloc.form.data %}
                    {% set label = item.label|default(null)%}
                    {% set placeholder = item.placeholder|default(null) %}
    
                    {% if item.type == "header" %}
                        <div class="col-12">
                            {{ forms.header(item.subtype,item.label,item.className) }}
                        </div>
    
    
                    {% elseif item.type == 'date' %}
                        <div class="form-group col-sm-12 col-md-6 {{ item.classGlobal is defined ? item.classGlobal : '' }}" >
                            {{ forms.input(item.name,placeholder,item.className,item.required,item.type,label) }}
    
                            <div class="invalid-feedback">
                                {{item.ErrorMessage|default(message)}}
                            </div>
                        </div>
    
                    {% elseif item.type == "text" %}
                        <div {% if item.classGlobal is defined %} class="{{item.classGlobal}} {{item.name == 'ctc_city'?'ctc_city':''}}" {% else %} class="col-sm-6 {{item.name == 'ctc_city'?'ctc_city':''}}" {% endif %}>
                            <div class="form-group {{ item.required == "true" ? 'required' : '' }}">
                                {{ forms.input(item.name,item.type,item.className,item.required,item.subtype,label,placeholder,item.maxlength|default(null)) }}
                                <div class="invalid-feedback">
                                    {% if item.name == 'ctc_postcode' %}
                                         {{'validation_code_postal'|trans([],'variable')}}
                                    {% else %}
                                        {{item.ErrorMessage|default(message)}}
                                    {% endif %}
                                </div>
                            </div>
                        </div>
    
                    {% elseif item.type == "number" %}
                        <div {% if item.classGlobal is defined %} class="{{item.classGlobal}}" {% else %} class="col-sm-6 " {% endif %}>
                            <div class="form-group {{ item.required == "true" ? 'required' : '' }}">
                                {# {{ forms.text(item.name,item.type,item.className,item.required,label,placeholder,item.maxlength|default(null)) }} #}
                                {% if item.label is defined %}<label>{{item.label|raw}}</label>{% endif %}
                                <input type="number" name="{{item.name}}" placeholder="{{item.placeholder is defined ? item.placeholder:''}}" class="form-control {{item.className is defined ? item.className:''}}" {{ item.required == "true" ? 'required' : '' }} data-form-input/>
                                <div class="invalid-feedback">
                                    {{item.ErrorMessage|default(message)}}
                                </div>
                            </div>
                        </div>
                        
                        {% if item.name == 'ctc_city' %}
                            {{ render(controller('App\\Controller\\Front\\FunctionController::renderCitySelectForm', {'class' : item.classGlobal, 'required' : item.required,'name':item.name,'label':item.label})) }}
                        {% endif %}
                    {% elseif item.type == "select" %}
                        <div {% if item.classGlobal is defined %} class="{{item.classGlobal}}" {% else %} class="col-sm-6" {% endif %}>
                            <div class="form-group {{ item.required == "true" ? 'required' : '' }}">
                                {{ forms.select(item.type,item.name,item.className,item.required,item.multiple,item.values,label,placeholder) }}
                                <div class="invalid-feedback">
                                    {{item.ErrorMessage|default(message)}}
                                </div>
                            </div>
                        </div>
    
                    {% elseif item.type == "textarea" %}
                        <div {% if item.classGlobal is defined %} class="{{item.classGlobal}}" {% else %} class="col-sm-12" {% endif %}>
                            <div class="form-group {{ item.required == "true" ? 'required' : '' }}">
                                {{ forms.textarea(item.name,item.type,item.className|default(''),item.required,item.subtype,label|replace({'<br>':''}),placeholder,item.rows|default('3')) }}
                                {% if item.required %}
                                <div class="invalid-feedback">
                                    {{item.ErrorMessage|default(message)}}
                                </div>
                                {% endif %}
                            </div>
                        </div>
                    {% elseif item.type == "file" %}
                            <div {% if item.classGlobal is defined %} class="col-md-6 col-lg-4 input-file {{item.classGlobal}}" {% else %} class="col-md-6 text-left" {% endif %}>
                                <div class="form-group">
                                    {{ forms.input(item.name,item.type,item.className|default(''),item.required,item.subtype,label,placeholder,item.maxlength|default(null)) }}
                                    <div class="invalid-feedback">
                                        {{item.ErrorMessage|default(message)}}
                                    </div>
                                </div>
                            </div>
                    {% elseif item.type == "checkbox-group" %}
                        <div class="{% if item.classGlobal is defined %}{{item.classGlobal}}{% else %}col-sm-12{% endif %}">
                            {% if label %}<label>{{label}}</label>{% endif %}
                            <div class="form-group {{ item.required == "true" ? 'required' : '' }} {% if item.inline is defined and item.inline == "true" %}d-flex{% endif %}">
                                {{ forms.checkbox(item.required,item.name,item.values) }}
                            </div>
                        </div>
                    {% elseif item.type == "radio-group" %}
                        <div class="{% if item.classGlobal is defined %}{{item.classGlobal}}{% else %}col-sm-12{% endif %}">
                            <div class="form-group {{ item.required == "true" ? 'required' : '' }} {% if item.inline is defined and item.inline == "true" %}d-flex{% endif %}">
                                {% if item.label %}<label class="required">{{item.label}} : </label>{% endif %}
                                <div class="radio-group">
                                    {% for key,value in item.values %}
                                        <div class="radio-item">
                                        <input type="radio" name="{{item.name}}" id="{{item.name}}-{{key}}" value="{{value.value}}" {% if value.selected is defined and value.selected %}checked{% endif %}><label for="{{item.name}}-{{value.value}}">{{value.label}}</label>
                                        </div>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>
                    {% elseif item.type == "paragraph" %}
                        <div class="{% if item.classGlobal is defined %}{{item.classGlobal}}{% else %}col-sm-12{% endif %}">
                            <p>{{item.label|unescape|raw}}</p>
                        </div>
                    {% endif %}
                {% endfor %}
    
                {% if parametre.typerecaptcha == 2 and parametre.clekey != null %}
                    <div class="col-md-12 form-group text-center">
                        <div class="g-recaptcha" id="{{bloc.form.id}}_captcha" data-sitekey="{{parametre.clekey}}"></div>
                    </div>
                {% endif %}
    
                {% for item in bloc.form.data %}
                    {% set label = item.label|default(null)%}
                    {% set placeholder = item.placeholder|default(null) %}
    
                    {% if item.type == "button" %}
                        <div {% if item.classGlobal is defined %} class="{{item.classGlobal}}" {% else %} class="col-sm-12" {% endif %}>
                            <div class="form-group text-center">
                                {{ forms.button(item.name,item.type,item.subtype,item.className,item.label) }}
                            </div>
                        </div>
                    {% endif %}
    
                {% endfor %}
    
            </div>
            {% if parametre.typerecaptcha == 1 %}
                <input type="hidden" id="{{bloc.form.id}}_captcha" name="g-recaptcha-response" value="">
                {# <script src="https://www.google.com/recaptcha/api.js?render={{ParametreSite().clekey}}"></script> #}
            {% endif %}
    
        </form>
        </div>
        </section>
    {% endif %}