From 0719f42cb328f0fdc428191a12be7e693de9db2e Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 23 Sep 2026 13:07:44 +0200 Subject: [PATCH] fix: render export form checkboxes as real checkboxes The widgets lacked the form-check-input class, so NetBox's CSS showed them as empty text inputs with no visible checked state. Also pass role PKs as initial value so all device roles in scope are preselected. Co-Authored-By: Claude Opus 5.5 --- netbox_customer_export/forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox_customer_export/forms.py b/netbox_customer_export/forms.py index eb29700..73db24f 100644 --- a/netbox_customer_export/forms.py +++ b/netbox_customer_export/forms.py @@ -67,12 +67,16 @@ class ExportForm(forms.Form): def __init__(self, *args, scope=None, **kwargs): super().__init__(*args, **kwargs) + # Ohne diese Klasse stellt NetBox' CSS die Checkboxen als leere Eingabefelder dar + for field in self.fields.values(): + if isinstance(field.widget, (forms.CheckboxInput, forms.CheckboxSelectMultiple)): + field.widget.attrs["class"] = "form-check-input" self.fields["branding"].choices = [(k, b["name"]) for k, b in get_brandings().items()] if scope is not None: role_ids = scope.devices().values("role") roles = DeviceRole.objects.filter(pk__in=role_ids).order_by("name") self.fields["roles"].queryset = roles - self.fields["roles"].initial = list(roles) + self.fields["roles"].initial = [r.pk for r in roles] self.fields["title"].initial = f"Netzwerkdokumentation {scope.obj}" self.fields["subtitle"].initial = f"{scope.label}: {scope.obj}" if not get_plugin_config("netbox_customer_export", "allow_secrets"):