Skip to content

Commit

Permalink
Define form attrs inside dunder init
Browse files Browse the repository at this point in the history
This make filter fields render correctly
  • Loading branch information
podliashanyk committed Nov 8, 2024
1 parent ab89d12 commit fd88b5c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions python/nav/web/seeddb/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ class RoomFilterForm(forms.Form):
Location.objects.order_by('id').all(), required=False
)
location.widget.attrs.update({"class": "select"})
attrs = get_single_layout(heading="Filter rooms", row=[location])

def __init__(self, *args, **kwargs):
super(RoomFilterForm, self).__init__(*args, **kwargs)
self.attrs = get_single_layout(
heading="Filter rooms", filter_fields=[self["location"]]
)


class RoomForm(forms.ModelForm):
Expand Down Expand Up @@ -285,7 +290,12 @@ class NetboxTypeFilterForm(forms.Form):
"""Form for filtering a netbox type by vendor"""

vendor = forms.ModelChoiceField(Vendor.objects.order_by('id').all(), required=False)
attrs = get_single_layout(heading="Filter types", row=[vendor])

def __init__(self, *args, **kwargs):
super(NetboxTypeFilterForm, self).__init__(*args, **kwargs)
self.attrs = get_single_layout(
heading="Filter types", filter_fields=[self["vendor"]]
)


class NetboxTypeForm(forms.ModelForm):
Expand Down

0 comments on commit fd88b5c

Please sign in to comment.