widgets: display formatted date in readonly fields (#42027)

This commit is contained in:
Frédéric Péters 2020-04-23 11:05:12 +02:00 committed by Thomas NOEL
parent d15bef1e53
commit 403cee7354
1 changed files with 4 additions and 1 deletions

View File

@ -5,8 +5,11 @@
type="{% if "readonly" in widget.attrs %}text{% else %}date{% endif %}"
{% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %}
{% if widget.required %}aria-required="true"{% endif %}
{% if "readonly" in widget.attrs %}
{% if widget.value %}value="{{ widget.value }}"{% endif %}
{% else %}
{% if widget.value %}value="{{ widget.value|date:"Y-m-d" }}" data-formatted-value="{{ widget.value }}"{% endif %}
{% if not "readonly" in widget.attrs %}
class="date-pick"
data-date-format="{{widget.date_format}}"