diff --git a/dojo/templates/dojo/form_fields.html b/dojo/templates/dojo/form_fields.html index f80fdbb3109..5a26d3bc6e6 100644 --- a/dojo/templates/dojo/form_fields.html +++ b/dojo/templates/dojo/form_fields.html @@ -1,4 +1,5 @@ {% load event_tags %} +{% load display_tags %} {% block css %} {{ form.media.css }} {% endblock %} @@ -17,6 +18,16 @@ {{ field }} {% endfor %} +{% if form|has_required_field %} +
+
+

+ Required fields are marked with an asterisk* +

+
+
+{% endif %} + {% for field in form.visible_fields %}
{% if field|is_checkbox %} diff --git a/dojo/templates_classic/dojo/form_fields.html b/dojo/templates_classic/dojo/form_fields.html index 6af19a96aa9..154400f1d6a 100644 --- a/dojo/templates_classic/dojo/form_fields.html +++ b/dojo/templates_classic/dojo/form_fields.html @@ -1,4 +1,5 @@ {% load event_tags %} +{% load display_tags %} {% block css %} {{ form.media.css }} {% endblock %} @@ -16,6 +17,16 @@ {{ field }} {% endfor %} +{% if form|has_required_field %} +
+
+

+ Required fields are marked with an asterisk* +

+
+
+{% endif %} + {% for field in form.visible_fields %}
{% if field|is_checkbox %} diff --git a/dojo/templatetags/display_tags.py b/dojo/templatetags/display_tags.py index b02f57ea828..5c73a259baa 100644 --- a/dojo/templatetags/display_tags.py +++ b/dojo/templatetags/display_tags.py @@ -1167,3 +1167,11 @@ def import_history(finding, *, autoescape=True): list_of_status_changes += "" + status_change.created.strftime("%b %d, %Y, %H:%M:%S") + ": " + status_change.get_action_display() + "
" return mark_safe(html % (list_of_status_changes)) + +@register.filter +def has_required_field(form): + """Returns True if the form has at least one required field""" + if not form: + return False + return any(field.field.required for field in form) +