{% extends 'includes/form/form-control.html.twig' %}
{% set hiddenInputAttribtes = [ 'name', 'value', 'placeholder' ] %}
{% block input %}
<div class="js-datepicker"
{% if min is defined %}data-datepicker-min-date="{{ min }}"{% endif %}
{% if max is defined %}data-datepicker-max-date="{{ max }}"{% endif %}
{% if numberOfMonths|default(1) %}data-datepicker-show-months="{{ numberOfMonths|default(1) }}"{% endif %}
>
{# This input contains the formatted date (according to locale) - don't use it in backend #}
<input
class="js-datepicker__input form-control {{ (errors|default([])|length > 0 ) ? 'is-invalid': '' }} {{ inputModifier|default('') }}"
readonly
{% for key, value in inputAttributes|default([])|filter((key, value) => not key in hiddenInputAttribtes) %}
{{ key }}="{{ value }}"
{% endfor %}
>
{# 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 class="js-datepicker__alt-field" name="{{ name }}" type="hidden" value="{{ value|default('') }}">
</div>
{% endblock %}
{% block label %}
<div class="datepicker__label">
{% if icon|default(false) %}
<span class="icon icon-{{ icon }} datepicker__icon" aria-hidden="true"></span>
{% endif %}
<span>{{ label }}</span>
</div>
{% endblock %}