{% do jsConfig().add('datepicker', true) %}
{% set errors = errors | default([]) %}
<div class="form-group js-datepicker datepicker {{ (errors | length > 0) ? 'has-error': '' }} {{ styleModifier|default('') }}"
{% if min|default(false) %}
data-datepicker-min-date="{{ min }}"
{% endif %}
{% if max|default(false) %}
data-datepicker-min-date="{{ max }}"
{% endif %}
{% if numberOfMonths|default(false) %}
data-datepicker-number-of-months="{{ numberOfMonths }}"
{% endif %}
>
<div class="{{ inputWrapperModifier|default('') }}">
{# This input contains the formatted date (according to locale) - don't use it in backend #}
<input
class="js-datepicker__input form-control {{ (errors | length > 0 )? 'is-invalid': '' }} {{ inputModifier|default('') }}"
name="{{ name }}-fake"
id="{{ id }}"
value=""
{{ required|default(false) ? 'required' : '' }}
{{ disabled|default(false) ? 'disabled' : '' }}
readonly
{{ helpText | default(null) ? 'aria-describedby="' ~ id ~'-help-block"' : '' }}
{% for key, value in inputAttributes | default([]) %}
{{key}}="{{value}}"
{% endfor %}
>
{{ include('Form/Includes/form-control-label.html.twig', _context) }}
{# Use the value of the following input in backend. It contains the selected date in the format 'Y-m-d\TH:i:s' (like ISO 8601 without timezone) #}
<input type="hidden"
name="{{ name }}"
value="{{ value }}"
class="form-control js-datepicker__alt-field {{ inputHiddenModifier|default('') }}"
readonly>
</div>
{{ include('Form/Includes/form-errors.html.twig', _context) }}
{{ include('Form/Includes/form-control-help-text.html.twig', _context) }}
</div>