[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - widget.py:1.3
Albertas Agejevas
alga@codeworks.lt
Mon, 30 Dec 2002 14:40:19 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv3966
Modified Files:
widget.py
Log Message:
Made CheckBoxWidget work.
Fixed an error in a raise, added more tests.
=== Zope3/src/zope/app/browser/form/widget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.2 Wed Dec 25 09:12:32 2002
+++ Zope3/src/zope/app/browser/form/widget.py Mon Dec 30 14:39:48 2002
@@ -55,7 +55,9 @@
if value is self:
# No user input
if field.required and not optional:
- raise MissingInputError(field.__name__)
+ # XXX this code path is not tested
+ raise MissingInputError(field.__name__, field.title,
+ 'the field is required')
return field.default
try:
@@ -166,6 +168,19 @@
cssClass = self.getValue('cssClass'),
size = self.getValue('displayWidth'),
extra = self.getValue('extra'))
+
+ def _convert(self, value):
+ return value == 'on'
+
+ def haveData(self):
+ return True
+
+ def getData(self, optional=0):
+ # When it's checked, its value is 'on'.
+ # When a checkbox is unchecked, it does not appear in the form data.
+ field = self.context
+ value = self.request.form.get(self.name, 'off')
+ return value == 'on'
class PossiblyEmptyMeansMissing: