Commits

Kevin Wetzels committed 46786dc

Fix error in form field that did not allow empty values to be passed in

  • Participants
  • Parent commits 2db724f

Comments (0)

Files changed (2)

stdfields/forms.py

         super(MinutesField, self).__init__(*args, **kwargs)
 
     def clean(self, value):
+        if not value:
+            return super(MinutesField, self).clean(value)
         value = smart_str(value).strip()
         match = re.search(r'^(\d+):(\d{1,2})$', value)
         if match:

stdfields/tests.py

         minutes = 480
         for i in range(60):
             self.assertEqual(minutes + i, f.clean('8:%d' % (i)))
+        # No errors on empty value when the field is not required
+        f.required = False
+        f.clean(None)
 
     def test_minutes_field_invalid(self):
         f = MinutesFormField()