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)
del c.title
c.instructions = ''
to_be_removed = []
for f in c.iter_fields():
if f.required:
# Keep all required fields
continue
if (hasattr(f, 'value') and not f.value) or (hasattr(f, 'values') and \
len(f.values) == 0):
c.delChild(f)
to_be_removed.append(f)
else:
del f.label
del f.description
for f in to_be_removed:
c.delChild(f)
return c
class MultipleDataForm(DataForm):
@ -458,4 +461,4 @@ class MultipleDataForm(DataForm):
# return locals()
# vim: se ts=3:
# vim: se ts=3: