diff --git a/babybuddy/static_src/scss/_global.scss b/babybuddy/static_src/scss/_global.scss index bdf3e949..eece0ec1 100644 --- a/babybuddy/static_src/scss/_global.scss +++ b/babybuddy/static_src/scss/_global.scss @@ -5,3 +5,8 @@ right: 0; left: auto; // Reset the default from `.dropdown-menu` } + +// BB form fields do not follow typical BS4 style that enables this display. +.invalid-feedback { + display: block; +} \ No newline at end of file diff --git a/babybuddy/templates/babybuddy/form.html b/babybuddy/templates/babybuddy/form.html index ac485edb..414befc8 100644 --- a/babybuddy/templates/babybuddy/form.html +++ b/babybuddy/templates/babybuddy/form.html @@ -3,12 +3,26 @@
{% csrf_token %} + {% if form.non_field_errors %} + {% for error in form.non_field_errors %} + + {% endfor %} + {% elif form.errors %} + + {% endif %} {% for field in form %} -
{{ field|field_type }}
- {% if field|field_type == "booleanfield" %} -
 
-
+ +
+ {% if field|field_type == "booleanfield" %}
-
- {% elif field|field_type == "datetimefield" or field|field_type == "datefield" %} - -
+ {% elif field|field_type == "datetimefield" or field|field_type == "datefield" %}
@@ -35,23 +46,20 @@ {% endif %}
-
- {% else %} - -
+ {% else %} {% if field.errors %} {{ field|add_class:"form-control is-invalid" }} {% else %} {{ field|add_class:"form-control" }} {% endif %} -
- {% endif %} - {% if field.help_text %} -

{{ field.help_text }}

- {% endif %} - {% if field.errors %} -

{% for error in field.errors %}{{ error }}{% endfor %}

- {% endif %} + {% endif %} + {% if field.help_text %} +
{{ field.help_text }}
+ {% endif %} + {% if field.errors %} +
{% for error in field.errors %}{{ error }}{% endfor %}
+ {% endif %} +
{% endfor %}