mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-24 19:32:53 +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):
|
||||
"""Widget that has an input box for every language."""
|
||||
template_name = 'localized_fields/multiwidget.html'
|
||||
widget = forms.Textarea
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -22,6 +23,10 @@ class LocalizedFieldWidget(forms.MultiWidget):
|
||||
|
||||
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]:
|
||||
"""Decompresses the specified value so
|
||||
it can be spread over the internal widgets.
|
||||
|
Loading…
x
Reference in New Issue
Block a user