diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index b673a3eb2..b0334ae78 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -237,7 +237,7 @@ class TF(object): def setdefaultvalues(self): "set default values and convert numbers to strings" - for (field, descr) in self.formdescription: + for field, descr in self.formdescription: # special case for boolcheckbox if descr.get("input_type", None) == "boolcheckbox" and self.submitted(): if field not in self.values: @@ -278,7 +278,7 @@ class TF(object): "check values. Store .result and returns msg" ok = 1 msg = [] - for (field, descr) in self.formdescription: + for field, descr in self.formdescription: val = self.values[field] # do not check "unckecked" items if descr.get("withcheckbox", False): @@ -287,7 +287,7 @@ class TF(object): # null values allow_null = descr.get("allow_null", True) if not allow_null: - if val == "" or val == None: + if val is None or (isinstance(val, str) and not val.strip()): msg.append( "Le champ '%s' doit ĂȘtre renseignĂ©" % descr.get("title", field) ) @@ -871,7 +871,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts); def _ReadOnlyVersion(self, formdescription): "Generate HTML for read-only view of the form" R = ['