From d2968c95dfdc08418a4f1f767f7e40f72f488195 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Tue, 11 Jan 2022 15:02:10 -0500 Subject: [PATCH] Fixes #8314: Prevent custom fields with default values from appearing as applied filters erroneously --- docs/release-notes/version-3.1.md | 1 + netbox/extras/forms/customfields.py | 2 +- netbox/extras/models/customfields.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index b9ffb40ec..88a33b923 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -16,6 +16,7 @@ * [#8301](https://github.com/netbox-community/netbox/issues/8301) - Fix delete button for various object children views * [#8305](https://github.com/netbox-community/netbox/issues/8305) - Fix assignment of custom field data to FHRP groups via UI * [#8306](https://github.com/netbox-community/netbox/issues/8306) - Redirect user to previous page after login +* [#8314](https://github.com/netbox-community/netbox/issues/8314) - Prevent custom fields with default values from appearing as applied filters erroneously * [#8317](https://github.com/netbox-community/netbox/issues/8317) - Fix CSV import of multi-select custom field values --- diff --git a/netbox/extras/forms/customfields.py b/netbox/extras/forms/customfields.py index d58e6ce65..7d5b40894 100644 --- a/netbox/extras/forms/customfields.py +++ b/netbox/extras/forms/customfields.py @@ -121,5 +121,5 @@ class CustomFieldModelFilterForm(FilterForm): ) for cf in custom_fields: field_name = f'cf_{cf.name}' - self.fields[field_name] = cf.to_form_field(set_initial=True, enforce_required=False) + self.fields[field_name] = cf.to_form_field(set_initial=False, enforce_required=False) self.custom_field_filters.append(field_name) diff --git a/netbox/extras/models/customfields.py b/netbox/extras/models/customfields.py index 9a940407a..2c2b0ef51 100644 --- a/netbox/extras/models/customfields.py +++ b/netbox/extras/models/customfields.py @@ -239,7 +239,7 @@ class CustomField(ChangeLoggedModel): """ Return a form field suitable for setting a CustomField's value for an object. - set_initial: Set initial date for the field. This should be False when generating a field for bulk editing. + set_initial: Set initial data for the field. This should be False when generating a field for bulk editing. enforce_required: Honor the value of CustomField.required. Set to False for filtering/bulk editing. for_csv_import: Return a form field suitable for bulk import of objects in CSV format. """