Code

Ticket #17921: base_form_css_class.diff

File base_form_css_class.diff, 1.1 KB (added by hanson2010, 2 years ago)

add error_css_class and required_css_class to BaseForm's init method

Line 
1Index: django/forms/forms.py
2===================================================================
3--- django/forms/forms.py       (revision 15452)
4+++ django/forms/forms.py       (working copy)
5@@ -71,7 +71,8 @@
6     # class, not to the Form class.
7     def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
8                  initial=None, error_class=ErrorList, label_suffix=':',
9-                 empty_permitted=False):
10+                 empty_permitted=False, error_css_class='error',
11+                 required_css_class='required'):
12         self.is_bound = data is not None or files is not None
13         self.data = data or {}
14         self.files = files or {}
15@@ -83,6 +84,8 @@
16         self.empty_permitted = empty_permitted
17         self._errors = None # Stores the errors after clean() has been called.
18         self._changed_data = None
19+        self.error_css_class = error_css_class
20+        self.required_css_class = required_css_class
21 
22         # The base_fields class attribute is the *class-wide* definition of
23         # fields. Because a particular *instance* of the class might want to