Formulaires anciens: allow_null n'accepte plus de champs blancs

This commit is contained in:
Emmanuel Viennet 2023-09-28 17:30:36 +02:00
parent f333975ec5
commit f547b800a1

View File

@ -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 = ['<table class="tf-ro">']
for (field, descr) in formdescription:
for field, descr in formdescription:
R.append(self._ReadOnlyElement(field, descr))
R.append("</table>")
return R