diff --git a/python/nav/django/templatetags/forms.py b/python/nav/django/templatetags/forms.py new file mode 100644 index 0000000000..255300d1df --- /dev/null +++ b/python/nav/django/templatetags/forms.py @@ -0,0 +1,12 @@ +"""Template filters for forms""" + +from django import forms, template + +register = template.Library() + + +# Copied from +# https://github.com/django-crispy-forms/django-crispy-forms/blob/1.8.1/crispy_forms/templatetags/crispy_forms_field.py +@register.filter +def is_checkbox(field): + return isinstance(field.field.widget, forms.CheckboxInput) diff --git a/python/nav/web/templates/foundation-5/field.html b/python/nav/web/templates/foundation-5/field.html index 15a37ccf60..279b5ccde5 100644 --- a/python/nav/web/templates/foundation-5/field.html +++ b/python/nav/web/templates/foundation-5/field.html @@ -1,24 +1,24 @@ -{% load crispy_forms_field %} +{% load forms %} {% if field.is_hidden %} {{ field }} {% else %}
+ class="ctrlHolder{% if field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}" + > {% spaceless %} {% if field.label %} {% if field|is_checkbox %} - {% crispy_field field %} + {{ field }} {% endif %}
diff --git a/python/nav/web/templates/seeddb/_form_fields.html b/python/nav/web/templates/seeddb/_form_fields.html index 582491b806..a7f47e9f4a 100644 --- a/python/nav/web/templates/seeddb/_form_fields.html +++ b/python/nav/web/templates/seeddb/_form_fields.html @@ -1,18 +1,3 @@ {% for field in form %} -
- - {{ field }} - {% for error in field.errors %} - - {{ error }} - - {% endfor %} -
+ {% include "foundation-5/field.html" %} {% endfor %}