[boolean field] we've to override format_single_value as well in case where None are allowed stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 17 Sep 2010 17:25:51 +0200
branchstable
changeset 6285 b8a2c9b9a2cb
parent 6284 c35b2ebeb3c9
child 6286 4d10e9895679
[boolean field] we've to override format_single_value as well in case where None are allowed
web/formfields.py
--- a/web/formfields.py	Fri Sep 17 17:25:17 2010 +0200
+++ b/web/formfields.py	Fri Sep 17 17:25:51 2010 +0200
@@ -871,6 +871,15 @@
         # XXX empty string for 'no' in that case for bw compat
         return [(form._cw._('yes'), '1'), (form._cw._('no'), '')]
 
+    def format_single_value(self, req, value):
+        """return value suitable for display"""
+        if self.allow_none:
+            if value is None:
+                return u''
+            if value is False:
+                return '0'
+        return super(BooleanField, self).format_single_value(req, value)
+
     def _ensure_correctly_typed(self, form, value):
         if self.allow_none:
             if value: