diff --git a/netbox/netbox/views/generic/bulk_views.py b/netbox/netbox/views/generic/bulk_views.py index 91d8dec94..f025de9df 100644 --- a/netbox/netbox/views/generic/bulk_views.py +++ b/netbox/netbox/views/generic/bulk_views.py @@ -162,14 +162,22 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin): # Render the objects table table = self.get_table(self.queryset, request, has_bulk_actions) - # Check for filterset_form on this view, if a form exists - # * Apply to context for use by the filter form tab and initialize the form + # Check for filterset_form(s) on this view and/or the table, if a form exists: + # * If both exist, initialize both + # * If a filterset form for the table exists, only initialize the table filterset_form + # * If a filterset form exists for the view, initialize the filterset form # * Apply to the table for use by the table and initialize a separate instance of the form for use by the table # column filters # * Otherwise set to None - if self.filterset_form: + if self.filterset_form and table.filterset_form: + filterset_form = self.filterset_form(request.GET) + table.filterset_form = table.filterset_form(request.GET) + elif self.filterset_form and not table.filterset_form: filterset_form = self.filterset_form(request.GET) table.filterset_form = self.filterset_form(request.GET) + elif not self.filterset_form and table.filterset_form: + filterset_form = None + table.filterset_form = table.filterset_form(request.GET) else: filterset_form = None table.filterset_form = None diff --git a/netbox/utilities/templatetags/form_helpers.py b/netbox/utilities/templatetags/form_helpers.py index 9245d7cc8..bcb59226a 100644 --- a/netbox/utilities/templatetags/form_helpers.py +++ b/netbox/utilities/templatetags/form_helpers.py @@ -36,6 +36,9 @@ def getfield(form, fieldname): @register.filter() def get_filter_field(form, fieldname): + # Check for a table form column map attribute and use that to map form fields if set + if hasattr(form, '_table_form_column_map') and form._table_form_column_map.get(fieldname): + return getfield(form, form._table_form_column_map.get(fieldname)) return getfield(form, f'{fieldname}') or getfield(form, f'{fieldname}_id')