don't remove field in the loop that iter on them.

This commit is contained in:
Yann Leboulanger 2008-07-30 07:46:05 +00:00
parent b38cc15186
commit b3dd46acae
1 changed files with 5 additions and 2 deletions

View File

@ -391,16 +391,19 @@ class SimpleDataForm(DataForm, DataRecord):
c = SimpleDataForm(extend=self) c = SimpleDataForm(extend=self)
del c.title del c.title
c.instructions = '' c.instructions = ''
to_be_removed = []
for f in c.iter_fields(): for f in c.iter_fields():
if f.required: if f.required:
# Keep all required fields # Keep all required fields
continue continue
if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') and \ if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') and \
len(f.values) == 0): len(f.values) == 0):
c.delChild(f) to_be_removed.append(f)
else: else:
del f.label del f.label
del f.description del f.description
for f in to_be_removed:
c.delChild(f)
return c return c
class MultipleDataForm(DataForm): class MultipleDataForm(DataForm):
@ -458,4 +461,4 @@ class MultipleDataForm(DataForm):
# return locals() # return locals()
# vim: se ts=3: # vim: se ts=3: