Projet

Général

Profil

0001-forms-always-use-yyyy-mm-dd-for-date-input-values-41.patch

Frédéric Péters, 16 avril 2020 17:59

Télécharger (1,81 ko)

Voir les différences:

Subject: [PATCH] forms: always use yyyy-mm-dd for date input values (#41784)

 wcs/qommon/static/js/qommon.forms.js                | 4 ++++
 wcs/qommon/templates/qommon/forms/widgets/date.html | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
wcs/qommon/static/js/qommon.forms.js
33 33
  $('.date-pick').each(function() {
34 34
    if (this.type == "date") return;  // prefer native date widget
35 35
    var $date_input = $(this);
36
    $date_input.attr('type', 'text');
37
    if ($date_input.data('formatted-value')) {
38
      $date_input.val($date_input.data('formatted-value'));
39
    }
36 40
    var options = Object();
37 41
    options.autoclose = true;
38 42
    options.weekStart = 1;
wcs/qommon/templates/qommon/forms/widgets/date.html
5 5
  type="{% if "readonly" in widget.attrs %}text{% else %}date{% endif %}"
6 6
  {% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %}
7 7
  {% if widget.required %}aria-required="true"{% endif %}
8
  {% if widget.value %}value="{{ widget.value }}"{% endif %}
8
  {% if widget.value %}value="{{ widget.value|date:"Y-m-d" }}" data-formatted-value="{{ widget.value }}"{% endif %}
9 9
  {% if not "readonly" in widget.attrs %}
10 10
  class="date-pick"
11 11
  data-date-format="{{widget.date_format}}"
12
-