web/formfields.py
changeset 9217 b4ac21bf6019
parent 9205 ea32e964fbf8
parent 9213 312062f53981
child 9257 ce338133c92c
--- a/web/formfields.py	Tue Jul 30 20:31:57 2013 +0200
+++ b/web/formfields.py	Wed Aug 07 09:02:47 2013 +0200
@@ -506,7 +506,7 @@
             if field is self:
                 try:
                     value = field.process_form_value(form)
-                    if value is None and field.required:
+                    if field.no_value(value) and field.required:
                         raise ProcessFormError(form._cw._("required field"))
                     yield field, value
                 except UnmodifiedField:
@@ -517,6 +517,11 @@
                 for field, value in field.process_posted(form):
                     yield field, value
 
+    @staticmethod
+    def no_value(value):
+        """return True if the value can be considered as no value for the field"""
+        return value is None
+
 
 class StringField(Field):
     """Use this field to edit unicode string (`String` yams type). This field
@@ -1170,6 +1175,12 @@
             eids.add(typed_eid)
         return eids
 
+    @staticmethod
+    def no_value(value):
+        """return True if the value can be considered as no value for the field"""
+        # value is None is the 'not yet ready value, consider the empty set
+        return value is not None and not value
+
 
 _AFF_KWARGS = uicfg.autoform_field_kwargs