Ensure that item fields have the proper type.

The item fields were not setting their type based on the reported
field's type attribute, so values were not being encoded properly.

Fixes issue #121
This commit is contained in:
Lance Stout 2011-12-13 08:59:39 -08:00
parent fc8a13df5a
commit 9c6dde5d22

View file

@ -96,11 +96,11 @@ class Form(ElementBase):
self.xml.append(itemXML) self.xml.append(itemXML)
reported_vars = self['reported'].keys() reported_vars = self['reported'].keys()
for var in reported_vars: for var in reported_vars:
fieldXML = ET.Element('{%s}field' % FormField.namespace) field = FormField()
itemXML.append(fieldXML) field._type = self['reported'][var]['type']
field = FormField(xml=fieldXML)
field['var'] = var field['var'] = var
field['value'] = values.get(var, None) field['value'] = values.get(var, None)
itemXML.append(field.xml)
def add_reported(self, var, ftype=None, label='', desc='', **kwargs): def add_reported(self, var, ftype=None, label='', desc='', **kwargs):
kwtype = kwargs.get('type', None) kwtype = kwargs.get('type', None)