--- a/src/pyams_i18n/interfaces/widget.py Wed Apr 11 11:09:34 2018 +0200
+++ b/src/pyams_i18n/interfaces/widget.py Fri Apr 13 10:26:56 2018 +0200
@@ -24,6 +24,9 @@
class II18nWidget(IWidget):
"""I18n base widget interface"""
+ def set_mode(self, mode):
+ """Set given mode to widget and all it's sub-widgets"""
+
class II18nTextLineWidget(II18nWidget):
"""I18n text line widget interface"""
--- a/src/pyams_i18n/widget/__init__.py Wed Apr 11 11:09:34 2018 +0200
+++ b/src/pyams_i18n/widget/__init__.py Fri Apr 13 10:26:56 2018 +0200
@@ -73,10 +73,12 @@
@widgettemplate_config(mode='input', template='templates/i18n-input.pt', widget=II18nWidget, layer=IFormLayer)
@widgettemplate_config(mode='display', template='templates/i18n-input.pt', widget=II18nWidget, layer=IFormLayer)
+@widgettemplate_config(mode='hidden', template='templates/i18n-hidden.pt', widget=II18nWidget, layer=IFormLayer)
@implementer_only(II18nWidget)
class I18nWidget(HTMLInputWidget, Widget):
"""I18n base widget"""
+ widgets = None
widget_factory = None
@reify
@@ -136,6 +138,12 @@
widget.error = view
widget.value = value
+ def set_mode(self, mode):
+ if self.widgets:
+ for lang in self.langs:
+ self.widgets[lang].mode = mode
+ self.mode = mode
+
def extract(self, default=NO_VALUE):
result = {}
[result.setdefault(lang, self.widgets[lang].extract(default)) for lang in self.langs]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_i18n/widget/templates/i18n-hidden.pt Fri Apr 13 10:26:56 2018 +0200
@@ -0,0 +1,3 @@
+<tal:loop repeat="lang view/langs">
+ <tal:var replace="structure python:view.get_widget(lang).render()" />
+</tal:loop>