* fixed bug with setting boolean values in forms

* added setValues to forms
This commit is contained in:
Nathan Fritz 2009-10-27 01:05:30 +00:00
parent f84f02acff
commit 8dbf53594b

View file

@ -104,7 +104,7 @@ class Form(FieldContainer):
else: else:
form1.field[field.var].value = field.value form1.field[field.var].value = field.value
for option, label in field.options: for option, label in field.options:
if (option, label) not in form1.fields[field.var].options: if (option, label) not in form1.field[field.var].options:
form1.fields[field.var].addOption(option, label) form1.fields[field.var].addOption(option, label)
return form1 return form1
@ -123,6 +123,15 @@ class Form(FieldContainer):
result[field.var] = value result[field.var] = value
return result return result
def setValues(self, values={}):
for field in values:
if field in self.field:
if isintance(values[field], list) or isinstance(values[field], tuple):
for value in values[field]:
self.field[field].setValue(value)
else:
self.field[field].setValue(values[field])
def fromXML(self, xml): def fromXML(self, xml):
self.buildForm(xml) self.buildForm(xml)