diff --git a/python/nav/web/seeddb/forms/__init__.py b/python/nav/web/seeddb/forms/__init__.py index 6f67e1e897..fc866a275f 100644 --- a/python/nav/web/seeddb/forms/__init__.py +++ b/python/nav/web/seeddb/forms/__init__.py @@ -22,7 +22,7 @@ from django.utils.safestring import mark_safe from crispy_forms.helper import FormHelper -from crispy_forms_foundation.layout import Layout, Field, Fieldset, Row, Column +from crispy_forms_foundation.layout import Layout, Fieldset, Row, Column from nav.django.forms import HStoreField from nav.web.crispyforms import LabelSubmit @@ -372,6 +372,8 @@ class DeviceGroupForm(forms.ModelForm): netboxes = forms.ModelMultipleChoiceField( queryset=Netbox.objects.all(), required=False ) + netboxes.widget.attrs.update({"class": "select2"}) + no_crispy = True def __init__(self, *args, **kwargs): # If the form is based on an existing model instance, populate the @@ -380,13 +382,6 @@ def __init__(self, *args, **kwargs): initial = kwargs.setdefault('initial', {}) initial['netboxes'] = [n.pk for n in kwargs['instance'].netboxes.all()] forms.ModelForm.__init__(self, *args, **kwargs) - self.helper = FormHelper() - self.helper.form_tag = False - self.helper.layout = Layout( - 'id', - 'description', - Field('netboxes', css_class='select2'), - ) class Meta(object): model = NetboxGroup diff --git a/python/nav/web/seeddb/page/netboxgroup.py b/python/nav/web/seeddb/page/netboxgroup.py index 22e6fb8ddb..c11e812de1 100644 --- a/python/nav/web/seeddb/page/netboxgroup.py +++ b/python/nav/web/seeddb/page/netboxgroup.py @@ -118,7 +118,6 @@ def netboxgroup_edit(request, netboxgroup_id=None): DeviceGroupForm, netboxgroup_id, 'seeddb-netboxgroup-edit', - template='seeddb/edit_device_group.html', extra_context=extra_context, ) diff --git a/python/nav/web/templates/seeddb/_form_fields.html b/python/nav/web/templates/seeddb/_form_fields.html new file mode 100644 index 0000000000..582491b806 --- /dev/null +++ b/python/nav/web/templates/seeddb/_form_fields.html @@ -0,0 +1,18 @@ +{% for field in form %} +