Code

Ticket #5609: na2.diff

File na2.diff, 1.9 KB (added by oggie_rob, 7 years ago)

Short version - most changes in trunk

Line 
1Index: django/contrib/admin/options.py
2===================================================================
3--- django/contrib/admin/options.py     (revision 6843)
4+++ django/contrib/admin/options.py     (working copy)
5@@ -188,7 +188,15 @@
6             return formfield
7 
8         # For any other type of field, just call its formfield() method.
9-        return db_field.formfield(**kwargs)
10+        formfield = db_field.formfield(**kwargs)
11+        # append name to class
12+        if formfield: # else a non-editable field
13+            attrs = formfield.widget.attrs
14+            field_class = 'v%s' % (formfield.__class__.__name__)
15+            if attrs.get('class'): # prepend to existing classes
16+                field_class += ' %s' % attrs.get('class')
17+            attrs['class'] = field_class
18+        return formfield
19 
20     def _declared_fieldsets(self):
21         if self.fieldsets:
22Index: django/contrib/admin/widgets.py
23===================================================================
24--- django/contrib/admin/widgets.py     (revision 6843)
25+++ django/contrib/admin/widgets.py     (working copy)
26@@ -37,7 +37,7 @@
27               settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
28         
29     def __init__(self, attrs={}):
30-        super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10'})
31+        super(AdminDateWidget, self).__init__(attrs={'class': 'vDateField', 'size': '10', 'maxlength': '10'})
32 
33 class AdminTimeWidget(forms.TextInput):
34     class Media:
35@@ -45,7 +45,7 @@
36               settings.ADMIN_MEDIA_PREFIX + "js/admin/DateTimeShortcuts.js")
37 
38     def __init__(self, attrs={}):
39-        super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8'})
40+        super(AdminTimeWidget, self).__init__(attrs={'class': 'vTimeField', 'size': '8', 'maxlength': '8'})
41     
42 class AdminSplitDateTime(forms.SplitDateTimeWidget):
43     """