Skip to content

Commit c447860

Browse files
author
symon.vezina
committed
Added global required fields notice for WCAG H90 compliance
1 parent 706b9d5 commit c447860

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

dojo/templates/dojo/form_fields.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% load event_tags %}
2+
{% load display_tags %}
23
{% block css %}
34
{{ form.media.css }}
45
{% endblock %}
@@ -17,6 +18,16 @@
1718
{{ field }}
1819
{% endfor %}
1920

21+
{% if form|has_required_field %}
22+
<div class="form-group">
23+
<div class="col-sm-offset-2 col-sm-10">
24+
<p class="help-block">
25+
<em>Required fields are marked with an asterisk</em><sup>*</sup>
26+
</p>
27+
</div>
28+
</div>
29+
{% endif %}
30+
2031
{% for field in form.visible_fields %}
2132
<div class="form-group{% if field.errors %} has-error{% endif %}">
2233
{% if field|is_checkbox %}

dojo/templates_classic/dojo/form_fields.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% load event_tags %}
2+
{% load display_tags %}
23
{% block css %}
34
{{ form.media.css }}
45
{% endblock %}
@@ -16,6 +17,16 @@
1617
{{ field }}
1718
{% endfor %}
1819

20+
{% if form|has_required_field %}
21+
<div class="form-group">
22+
<div class="col-sm-offset-2 col-sm-10">
23+
<p class="help-block">
24+
<em>Required fields are marked with an asterisk</em><sup>*</sup>
25+
</p>
26+
</div>
27+
</div>
28+
{% endif %}
29+
1930
{% for field in form.visible_fields %}
2031
<div class="form-group{% if field.errors %} has-error{% endif %}">
2132
{% if field|is_checkbox %}

dojo/templatetags/display_tags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,3 +1167,11 @@ def import_history(finding, *, autoescape=True):
11671167
list_of_status_changes += "<b>" + status_change.created.strftime("%b %d, %Y, %H:%M:%S") + "</b>: " + status_change.get_action_display() + "<br/>"
11681168

11691169
return mark_safe(html % (list_of_status_changes))
1170+
1171+
@register.filter
1172+
def has_required_field(form):
1173+
"""Returns True if the form has at least one required field"""
1174+
if not form:
1175+
return False
1176+
return any(field.field.required for field in form)
1177+

0 commit comments

Comments
 (0)