web/formfields.py
branchstable
changeset 6285 b8a2c9b9a2cb
parent 6218 d37428222a63
child 6333 e3994fcc21c3
equal deleted inserted replaced
6284:c35b2ebeb3c9 6285:b8a2c9b9a2cb
   868             return super(BooleanField, self).vocabulary(form)
   868             return super(BooleanField, self).vocabulary(form)
   869         if self.allow_none:
   869         if self.allow_none:
   870             return [('', ''), (form._cw._('yes'), '1'), (form._cw._('no'), '0')]
   870             return [('', ''), (form._cw._('yes'), '1'), (form._cw._('no'), '0')]
   871         # XXX empty string for 'no' in that case for bw compat
   871         # XXX empty string for 'no' in that case for bw compat
   872         return [(form._cw._('yes'), '1'), (form._cw._('no'), '')]
   872         return [(form._cw._('yes'), '1'), (form._cw._('no'), '')]
       
   873 
       
   874     def format_single_value(self, req, value):
       
   875         """return value suitable for display"""
       
   876         if self.allow_none:
       
   877             if value is None:
       
   878                 return u''
       
   879             if value is False:
       
   880                 return '0'
       
   881         return super(BooleanField, self).format_single_value(req, value)
   873 
   882 
   874     def _ensure_correctly_typed(self, form, value):
   883     def _ensure_correctly_typed(self, form, value):
   875         if self.allow_none:
   884         if self.allow_none:
   876             if value:
   885             if value:
   877                 return bool(int(value))
   886                 return bool(int(value))