summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2020-08-11 14:59:09 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2020-08-14 08:29:31 (GMT)
commit3de06b197049c331eb6b2c89903cc5d3538773d7 (patch)
treefc124d08ce36bf76dcea15154c98906abb63b83e
parenta71378bd9eef198afc215bf41610c2d05d3c9467 (diff)
downloadgadjo-3de06b197049c331eb6b2c89903cc5d3538773d7.zip
gadjo-3de06b197049c331eb6b2c89903cc5d3538773d7.tar.gz
gadjo-3de06b197049c331eb6b2c89903cc5d3538773d7.tar.bz2
misc: explicit forms optional fields and add class to mark them (#40156)v1.4
-rw-r--r--gadjo/static/css/_forms.scss18
-rw-r--r--gadjo/templates/gadjo/widget.html6
2 files changed, 23 insertions, 1 deletions
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 %}
<div class="title">
{{ field.label_tag }}
- {% if field.field.required %}<span title="{% trans "This field is required." %}" class="required">*</span>{% endif %}
+ {% if field.field.required %}
+ <span title="{% trans "This field is required." %}" class="required">*</span>
+ {% else %}
+ <span class="optional">{% trans "(optional)" %}</span>
+ {% endif %}
</div>
{% endblock %}
{% block widget-content %}