templates/includes/form/date-picker.html.twig line 1

Open in your IDE?
  1. {% extends 'includes/form/form-control.html.twig' %}
  2. {% set hiddenInputAttribtes = [ 'name', 'value', 'placeholder' ] %}
  3. {% block input %}
  4.     <div class="js-datepicker"
  5.         {% if min is defined %}data-datepicker-min-date="{{ min }}"{% endif %}
  6.         {% if max is defined %}data-datepicker-max-date="{{ max }}"{% endif %}
  7.         {% if numberOfMonths|default(1) %}data-datepicker-show-months="{{ numberOfMonths|default(1) }}"{% endif %}
  8.     >
  9.         {# This input contains the formatted date (according to locale) - don't use it in backend #}
  10.         <input
  11.             class="js-datepicker__input form-control {{ (errors|default([])|length > 0 ) ? 'is-invalid': '' }} {{ inputModifier|default('') }}"
  12.             readonly
  13.             {% for key, value in inputAttributes|default([])|filter((key, value) => not key in hiddenInputAttribtes) %}
  14.                 {{ key }}="{{ value }}"
  15.             {% endfor %}
  16.         >
  17.         {# 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) #}
  18.         <input class="js-datepicker__alt-field" name="{{ name }}" type="hidden" value="{{ value|default('') }}">
  19.     </div>
  20. {% endblock %}
  21. {% block label %}
  22.     <div class="datepicker__label">
  23.         {% if icon|default(false) %}
  24.             <span class="icon icon-{{ icon }} datepicker__icon" aria-hidden="true"></span>
  25.         {% endif %}
  26.         <span>{{ label }}</span>
  27.     </div>
  28. {% endblock %}