From 3de06b197049c331eb6b2c89903cc5d3538773d7 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Tue, 11 Aug 2020 16:59:09 +0200 Subject: [PATCH] misc: explicit forms optional fields and add class to mark them (#40156) --- gadjo/static/css/_forms.scss | 18 ++++++++++++++++++ gadjo/templates/gadjo/widget.html | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gadjo/static/css/_forms.scss b/gadjo/static/css/_forms.scss index 44a57f4..60f3cfb 100644 --- a/gadjo/static/css/_forms.scss +++ b/gadjo/static/css/_forms.scss @@ -399,3 +399,21 @@ form.small button + a.button { .field-live-hint button.close::after { content: "×"; } + +form { + .widget-optional span.optional { + display: none; + } +} + +form.pk-mark-optional-fields { + .widget-required { + span.required { + display: none; + } + } + .widget-optional span.optional { + display: inline; + font-style: italic; + } +} diff --git a/gadjo/templates/gadjo/widget.html b/gadjo/templates/gadjo/widget.html index d1f2dae..a937698 100644 --- a/gadjo/templates/gadjo/widget.html +++ b/gadjo/templates/gadjo/widget.html @@ -7,7 +7,11 @@ {% block widget-title %}
{{ field.label_tag }} - {% if field.field.required %}*{% endif %} + {% if field.field.required %} + * + {% else %} + {% trans "(optional)" %} + {% endif %}
{% endblock %} {% block widget-content %}