# HG changeset patch # User Thierry Florac # Date 1523608016 -7200 # Node ID 3cbc6d17cdb53e603f864f484c212641235c17d2 # Parent 52d0811950e8c0c903fd15e9f6bb2f67f7ac8892 Added template for hidden I18n widget diff -r 52d0811950e8 -r 3cbc6d17cdb5 src/pyams_i18n/interfaces/widget.py --- 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""" diff -r 52d0811950e8 -r 3cbc6d17cdb5 src/pyams_i18n/widget/__init__.py --- 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] diff -r 52d0811950e8 -r 3cbc6d17cdb5 src/pyams_i18n/widget/templates/i18n-hidden.pt --- /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 @@ + + +