Skip to content

Commit

Permalink
Merge pull request #24 from toscawidgets/master
Browse files Browse the repository at this point in the history
Merge @moschlar's hotfix back into develop.
  • Loading branch information
ralphbean committed Jun 12, 2013
2 parents 7dc8339 + ab00c2e commit c7d5f83
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tw2/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class CheckBox(InputField):
type = "checkbox"
validator = twc.BoolValidator

def _validate(self, value, state=None):
# Since twc.BoolValidator returns None if no value is present
# (which is the common case if a HTML checkbox is not checked)
# we explicitly convert to bool again here
self.value = super(CheckBox, self)._validate(value, state)
return bool(self.value)

def prepare(self):
super(CheckBox, self).prepare()
checked = self.validator.to_python(self.value)
Expand Down

0 comments on commit c7d5f83

Please sign in to comment.