[form] CompoundField should not return itself in actual_fields, this avoid error on iliane with 3.7.2 where it's marked as required (from the schema) while value are provided by subfields stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Mar 2010 17:54:28 +0200
branchstable
changeset 5085 981e85b14b47
parent 5084 d8f491cb046c
child 5086 bd13d9268b44
[form] CompoundField should not return itself in actual_fields, this avoid error on iliane with 3.7.2 where it's marked as required (from the schema) while value are provided by subfields
web/formfields.py
--- a/web/formfields.py	Tue Mar 30 17:50:09 2010 +0200
+++ b/web/formfields.py	Tue Mar 30 17:54:28 2010 +0200
@@ -867,7 +867,7 @@
             eids.add(typed_eid)
         return eids
 
-
+# XXX use cases where we don't actually want a better widget?
 class CompoundField(Field):
     def __init__(self, fields, *args, **kwargs):
         super(CompoundField, self).__init__(*args, **kwargs)
@@ -877,7 +877,11 @@
         return self.fields
 
     def actual_fields(self, form):
-        return [self] + list(self.fields)
+        # don't add [self] to actual fields, compound field is usually kinda
+        # virtual, all interesting values are in subfield. Skipping it may avoid
+        # error when processed by the editcontroller : it may be marked as required
+        # while it has no value, hence generating a false error.
+        return list(self.fields)
 
 
 _AFF_KWARGS = uicfg.autoform_field_kwargs