Anonymous avatar Anonymous committed e410d1d

Fixed #1767 -- boolean fields may now have validators! Thanks, Joseph.

Comments (0)

Files changed (2)


         params['is_required'] = not self.blank and not self.primary_key and not rel
         # BooleanFields (CheckboxFields) are a special case. They don't take
-        # is_required or validator_list.
+        # is_required.
         if isinstance(self, BooleanField):
-            del params['validator_list'], params['is_required']
+            del params['is_required']
         # If this field is in a related context, check whether any other fields
         # in the related object have core=True. If so, add a validator --


             (self.get_id(), self.field_name, escape(data))
 class CheckboxField(FormField):
-    def __init__(self, field_name, checked_by_default=False):
+    def __init__(self, field_name, checked_by_default=False, validator_list=None):
+        if validator_list is None: validator_list = []
         self.field_name = field_name
         self.checked_by_default = checked_by_default
-        self.is_required, self.validator_list = False, [] # because the validator looks for these
+        self.is_required = False # because the validator looks for these
+        self.validator_list = validator_list[:]
     def render(self, data):
         checked_html = ''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.