{% extends "qommon/forms/widget.html" %}

{% block widget-control %}
<input id="form_{{widget.name}}" name="{{widget.name}}" type="text"
  {% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %}
  {% if widget.required %}aria-required="true"{% endif %}
  {% if widget.value %}value="{{ widget.value }}"{% endif %}
  {% if not "readonly" in widget.attrs %}
  class="date-pick"
  data-date-format="{{widget.date_format}}"

  {# if the date format does not contain the time, set widget not to go #}
  {# into the time pages #}
  data-min-view="{% if 'hh' in widget.date_format %}0{% else %}2{% endif %}"

  {# if there is no value we set the initial view to be the view of decades, #}
  {# it is more appropriate to select a far away date. #}
  data-start-view="{% if widget.value %}2{% else %}4{% endif %}"

  {% if widget.minimum_date %}data-start-date="{{ widget.start_date }}"{% endif %}
  {% if widget.maximum_date %}data-end-date="{{ widget.end_date }}"{% endif %}
  {% endif %}
  >
{% endblock %}
