Ticket #3515: fields.2.diff
File fields.2.diff, 1.4 KB (added by , 18 years ago) |
---|
-
fields.py
35 35 # Tracks each time a Field instance is created. Used to retain order. 36 36 creation_counter = 0 37 37 38 def __init__(self, required=True, widget=None, label=None, initial=None, help_text=None ):38 def __init__(self, required=True, widget=None, label=None, initial=None, help_text=None, css=None): 39 39 # required -- Boolean that specifies whether the field is required. 40 40 # True by default. 41 41 # widget -- A Widget class, or instance of a Widget class, that should be … … 48 48 # initial -- A value to use in this Field's initial display. This value is 49 49 # *not* used as a fallback if data isn't given. 50 50 # help_text -- An optional string to use as "help text" for this Field. 51 # css -- An optional string to set the CSS class name(s) for this Field. 51 52 if label is not None: 52 53 label = smart_unicode(label) 53 54 self.required, self.label, self.initial = required, label, initial … … 60 61 extra_attrs = self.widget_attrs(widget) 61 62 if extra_attrs: 62 63 widget.attrs.update(extra_attrs) 64 65 # Set initial CSS class name(s) 66 if css or required: 67 if required: css = (css or '') + 'required' 68 widget.attrs.update({'class': css.lstrip()}) 63 69 64 70 self.widget = widget