diff --git a/python/nav/web/arnold/forms.py b/python/nav/web/arnold/forms.py index 74fcea3fd7..fe9de939d7 100644 --- a/python/nav/web/arnold/forms.py +++ b/python/nav/web/arnold/forms.py @@ -22,7 +22,12 @@ from crispy_forms_foundation.layout import Layout, Fieldset, Div, Row, Submit, Column from nav.util import is_valid_ip, is_valid_mac -from nav.web.crispyforms import CheckBox +from nav.web.crispyforms import ( + CheckBox, + FlatFieldset, + SubmitField, + set_flat_form_attributes, +) from nav.models.arnold import ( DETENTION_TYPE_CHOICES, STATUSES, @@ -50,12 +55,15 @@ def __init__(self, *args, **kwargs): submit_value = 'Save changes' fieldset_legend = 'Edit detention reason' - # Create helper for crispy layout - self.helper = FormHelper() - self.helper.form_action = 'arnold-justificatons' - self.helper.layout = Layout( - Fieldset(fieldset_legend, 'name', 'description', 'justificationid'), - Submit('submit', submit_value, css_class='small'), + self.attrs = set_flat_form_attributes( + form_action='arnold-justificatons', + form_fields=[ + FlatFieldset( + fieldset_legend, + fields=[self['name'], self['description'], self['justificationid']], + ) + ], + submit_field=SubmitField(value=submit_value, css_classes='small'), ) diff --git a/python/nav/web/templates/arnold/justifications.html b/python/nav/web/templates/arnold/justifications.html index 23b2db4c73..a9bb20aff1 100644 --- a/python/nav/web/templates/arnold/justifications.html +++ b/python/nav/web/templates/arnold/justifications.html @@ -1,5 +1,4 @@ {% extends "arnold/tabs.html" %} -{% load crispy_forms_tags %} {% block tabcontent %} @@ -51,7 +50,11 @@ {% comment %} Form for creating new justifications {% endcomment %}
- {% crispy form %} + {% if form.attrs %} + {% include 'custom_crispy_templates/flat_form.html' %} + {% else %} + {{ form }} + {% endif %}