mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 11:42:54 +03:00
Add labels to localized subwidgets
This commit is contained in:
parent
d4c24dea97
commit
e8e044f6e2
@ -0,0 +1,4 @@
|
|||||||
|
{% for widget in widget.subwidgets %}
|
||||||
|
<label for="{{ widget.attrs.id }}">{{ widget.attrs.lang_name }}</label>
|
||||||
|
{% include widget.template_name %}
|
||||||
|
{% endfor %}
|
@ -10,6 +10,7 @@ from .value import LocalizedValue
|
|||||||
|
|
||||||
class LocalizedFieldWidget(forms.MultiWidget):
|
class LocalizedFieldWidget(forms.MultiWidget):
|
||||||
"""Widget that has an input box for every language."""
|
"""Widget that has an input box for every language."""
|
||||||
|
template_name = 'localized_fields/multiwidget.html'
|
||||||
widget = forms.Textarea
|
widget = forms.Textarea
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -22,6 +23,10 @@ class LocalizedFieldWidget(forms.MultiWidget):
|
|||||||
|
|
||||||
super().__init__(initial_widgets, *args, **kwargs)
|
super().__init__(initial_widgets, *args, **kwargs)
|
||||||
|
|
||||||
|
for ((lc, ln), w) in zip(settings.LANGUAGES, self.widgets):
|
||||||
|
w.attrs['lang_code'] = lc
|
||||||
|
w.attrs['lang_name'] = ln
|
||||||
|
|
||||||
def decompress(self, value: LocalizedValue) -> List[str]:
|
def decompress(self, value: LocalizedValue) -> List[str]:
|
||||||
"""Decompresses the specified value so
|
"""Decompresses the specified value so
|
||||||
it can be spread over the internal widgets.
|
it can be spread over the internal widgets.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user