From a73e8870ca455eabbb5f21bcfc66f963c57cb7e5 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Sat, 13 Jul 2024 09:37:39 +0200 Subject: [PATCH] fix: setting `DJANGOCMS_FRONTEND_MINIMUM_INPUT_LENGTH` caused a regression when updating opt groups (#230) --- djangocms_frontend/contrib/link/forms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/djangocms_frontend/contrib/link/forms.py b/djangocms_frontend/contrib/link/forms.py index cb8b7dd9..45f56f49 100644 --- a/djangocms_frontend/contrib/link/forms.py +++ b/djangocms_frontend/contrib/link/forms.py @@ -109,7 +109,8 @@ def build_attrs(self, base_attrs, extra_attrs=None): def optgroups(self, name, value, attr=None): groups = super(forms.Select, self).optgroups(name, value) - if not self.is_required: + if not self.is_required and groups: + # Add an empty entry to allow for an empty value to be preselected groups[0][1].insert(0, self.create_option(name, "", "", False, 0)) return groups