From 04c7b20c772f5078182bd5c435dac53304eea086 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 10 Aug 2010 18:25:45 +0200 Subject: [PATCH] always send at least an emtpy for every required fields when we send a dataform. Fixes #5829 --- src/adhoc_commands.py | 2 +- src/common/dataforms.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/adhoc_commands.py b/src/adhoc_commands.py index d04771445..b0835b474 100644 --- a/src/adhoc_commands.py +++ b/src/adhoc_commands.py @@ -616,7 +616,7 @@ class CommandWindow: cmdnode.setAttr('sessionid', self.sessionid) if self.data_form_widget.data_form: - cmdnode.addChild(node=self.data_form_widget.data_form) + cmdnode.addChild(node=self.data_form_widget.data_form.get_purged()) def callback(response): # FIXME: move to connection_handlers.py diff --git a/src/common/dataforms.py b/src/common/dataforms.py index 6d9b46f9c..d1c82e589 100644 --- a/src/common/dataforms.py +++ b/src/common/dataforms.py @@ -352,7 +352,7 @@ class StringField(DataField): def fset(self, value): assert isinstance(value, basestring) - if value == '': + if value == '' and not self.required: return fdel(self) self.setTagData('value', value) @@ -662,6 +662,11 @@ class SimpleDataForm(DataForm, DataRecord): to_be_removed = [] for f in c.iter_fields(): if f.required: + # add if there is not + if hasattr(f, 'value') and not f.value: + f.value = '' + if hasattr(f, 'values') and not f.values: + f.values = [''] # Keep all required fields continue if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') \