Ticket #5986: django-fields-weight.patch
File django-fields-weight.patch, 1.9 KB (added by , 17 years ago) |
---|
-
newforms/fields.py
50 50 creation_counter = 0 51 51 52 52 def __init__(self, required=True, widget=None, label=None, initial=None, 53 help_text=None, error_messages=None ):53 help_text=None, error_messages=None, weight=0): 54 54 # required -- Boolean that specifies whether the field is required. 55 55 # True by default. 56 56 # widget -- A Widget class, or instance of a Widget class, that should … … 64 64 # initial -- A value to use in this Field's initial display. This value 65 65 # is *not* used as a fallback if data isn't given. 66 66 # help_text -- An optional string to use as "help text" for this Field. 67 # weight -- An optional parameter to control Fields order in a Form. 67 68 if label is not None: 68 69 label = smart_unicode(label) 69 70 self.required, self.label, self.initial = required, label, initial … … 83 84 self.creation_counter = Field.creation_counter 84 85 Field.creation_counter += 1 85 86 87 self.weight = weight 88 86 89 self.error_messages = self._build_error_messages(error_messages) 87 90 88 91 def _build_error_messages(self, extra_error_messages): -
newforms/forms.py
37 37 for base in bases[::-1]: 38 38 if hasattr(base, 'base_fields'): 39 39 fields = base.base_fields.items() + fields 40 41 # Field weights override declaration and inheritance order. 42 fields.sort(lambda x, y: cmp(x[1].weight, y[1].weight)) 40 43 41 44 attrs['base_fields'] = SortedDict(fields) 42 45 return type.__new__(cls, name, bases, attrs)