Skip to content

Commit 74dd2de

Browse files
authored
fix: Improved handling of optional smart link field (#210)
1 parent 4763253 commit 74dd2de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

djangocms_frontend/contrib/link/forms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ def build_attrs(self, base_attrs, extra_attrs=None):
114114
return attrs
115115

116116
def optgroups(self, name, value, attr=None):
117-
return super(forms.Select, self).optgroups(name, value)
117+
groups = super(forms.Select, self).optgroups(name, value)
118+
if not self.is_required:
119+
groups[0][1].insert(0, self.create_option(name, "", "", False, 0))
120+
return groups
118121

119122

120123
class SmartLinkField(forms.ChoiceField):

0 commit comments

Comments
 (0)