{% import "front/"~ app.request.server.get('APP_THEME') ~"/form/macro_form.html.twig" as forms %}
{% set parametre = ParametreSite() %}
<section class="parallax-sec-form-lp position-relative py-5">
{% if bloc.form is defined and (bloc.form.image is defined and bloc.form.image is not empty) %}
<img class="bg-form-lp" src="{{asset(bloc.form.image)}}" alt="{{bloc.form.titre|default('')|raw}}">
{% endif %}
<div class="container-fluid wrapper">
<div class="row content-form-lp position-relative align-items-center">
{% if bloc.form is defined and (bloc.form.texte is defined and bloc.form.texte is not empty ) %}
<div class="col-sm-12 col-md-6 pr-5">
<div class="title">{{bloc.form.titre|default('')|raw}}</div>
{{bloc.form.texte|raw}}
</div>
{% endif %}
{% if bloc.form is defined %}
<div class="col-sm-12 col-md-6 ">
<div class="bloc-form-lp">
<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">
{% for item in bloc.form.data %}
{% if item.type == "paragraph" %}
<div class="titre-form-lp {% if item.classGlobal is defined %}{{item.classGlobal}}{% endif %}">
<h3 class="titre"><span>{{item.label|unescape|raw}}</span></h3>
</div>
{% endif %}
{% endfor %}
<div class="form-lp">
<div class="row">
{% for item in bloc.form.data %}
{% set label = item.label|default(null)%}
{% set placeholder = item.placeholder|default(null) %}
{% if 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>
{% endif %}
{% endfor %}
</div>
</div>
{% 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="bouton-form-lp {{item.classGlobal}}" {% else %} class="bouton-form-lp" {% endif %}>
<div class="form-group text-center">
{{ forms.button(item.name,item.type,item.subtype,item.className,item.label) }}
</div>
</div>
{% endif %}
{% endfor %}
{% 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>
</div>
{% endif %}
</div>
</div>
</section>