Skip to content

Commit b2e334a

Browse files
committed
fix: Show internal link targets in the plugin language
1 parent 144443b commit b2e334a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

djangocms_frontend/contrib/link/forms.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,16 @@ class Meta:
173173
)
174174
attributes = AttributesFormField()
175175
tag_type = TagTypeFormField()
176+
177+
def __init__(self, *args, **kwargs):
178+
"""
179+
Initialize the form with the language of the plugin edited for the link field widgets.
180+
"""
181+
super().__init__(*args, **kwargs)
182+
language = None
183+
if "instance" in kwargs:
184+
language = getattr(kwargs["instance"], "language", None)
185+
elif "initial" in kwargs and "plugin_language" in kwargs["initial"]:
186+
language = kwargs["initial"]["plugin_language"]
187+
for widget in self.fields["link"].widget.widgets:
188+
widget.language = language

0 commit comments

Comments
 (0)