strasbourg: use boolean field for single checkboxes
This commit is contained in:
parent
0169f3127c
commit
1652e35c5b
|
@ -104,11 +104,17 @@ def process_children(node):
|
|||
if field_type == 'hidden':
|
||||
continue
|
||||
|
||||
if field_type == 'checkbox':
|
||||
if len(field_node.findall('choices/choice')) > 1:
|
||||
field_type = 'items'
|
||||
|
||||
|
||||
field_klass = {
|
||||
'textinput': fields.StringField,
|
||||
'textarea': fields.TextField,
|
||||
'email': fields.EmailField,
|
||||
'checkbox': fields.ItemsField,
|
||||
'checkbox': fields.BoolField,
|
||||
'items': fields.ItemsField,
|
||||
'radio': fields.ItemField,
|
||||
'select1': fields.ItemField,
|
||||
'date': fields.DateField,
|
||||
|
@ -119,6 +125,9 @@ def process_children(node):
|
|||
label=fix_encoding(field_node.find('label').attrib['plain']))
|
||||
formdef.fields.append(field)
|
||||
|
||||
if field_type == 'checkbox':
|
||||
field.label = fix_encoding(field_node.findall('choices/choice/label')[0].attrib['plain'])
|
||||
|
||||
if field_type == 'radio':
|
||||
field.show_as_radio = True
|
||||
|
||||
|
@ -137,7 +146,7 @@ def process_children(node):
|
|||
if len(field_node.findall('hint')):
|
||||
field.hint = fix_encoding(field_node.find('hint').text or '')
|
||||
|
||||
if field_type in ('checkbox', 'radio', 'select1'):
|
||||
if field_type in ('items', 'radio', 'select1'):
|
||||
field.items = []
|
||||
for choice in field_node.findall('choices/choice'):
|
||||
field.items.append(fix_encoding(choice.find('label').attrib['plain']))
|
||||
|
|
Loading…
Reference in New Issue