Marconi Moreto  committed 69f65f7

added filter when processing BooleanField instead of assuming that an empty field won't be submitted

  • Participants
  • Parent commits b33c3fb
  • Branches default

Comments (0)

Files changed (1)

File wtforms/fields/
 = bool(value)
     def process_formdata(self, valuelist):
-        # Checkboxes and submit buttons simply do not send a value when
-        # unchecked/not pressed. So the actual value="" doesn't matter for
-        # purpose of determining .data, only whether one exists or not.
- = bool(valuelist)
+        # Its not safe to assume that an unchecked field won't be submitted,
+        # when using via ajax (ie. Backbone model's .save) sometimes its
+        # better to include the falsy field. So be safe, we filter valuelist
+        # instead and check if we can find a truthy value and cast to bool
+        # from there.
+ = bool(filter(lambda e: e, valuelist))
     def _value(self):
         if self.raw_data: