Ticket #3632: forms.py

File forms.py, 808 bytes (added by ludo@…, 18 years ago)

this one seems to work satisfactorily

Line 
1Index: newforms/forms.py
2===================================================================
3--- newforms/forms.py (revision 4637)
4+++ newforms/forms.py (working copy)
5@@ -46,7 +46,14 @@
6 if hasattr(base, 'base_fields'):
7 fields = base.base_fields.items() + fields
8
9- attrs['base_fields'] = SortedDictFromList(fields)
10+ # preserve initial values
11+ base_fields = SortedDictFromList(fields)
12+ if attrs.get('base_fields'):
13+ base_fields = base_fields.copy()
14+ for k, v in attrs.get('base_fields').items():
15+ if k in base_fields:
16+ base_fields[k].initial = v.initial
17+ attrs['base_fields'] = base_fields
18 return type.__new__(cls, name, bases, attrs)
19
20 class BaseForm(StrAndUnicode):
Back to Top