From b3dd46acaee256a0a650d2056c4c3c836fa4d004 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 30 Jul 2008 07:46:05 +0000 Subject: [PATCH] don't remove field in the loop that iter on them. --- src/common/dataforms.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/dataforms.py b/src/common/dataforms.py index 3dba7cf24..d0163a75a 100644 --- a/src/common/dataforms.py +++ b/src/common/dataforms.py @@ -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: \ No newline at end of file +# vim: se ts=3: