Ticket #9079: label_tag_r9027.diff
File label_tag_r9027.diff, 1.9 KB (added by , 16 years ago) |
---|
-
django/forms/fields.py
59 59 creation_counter = 0 60 60 61 61 def __init__(self, required=True, widget=None, label=None, initial=None, 62 help_text=None, error_messages=None, show_hidden_initial=False ):62 help_text=None, error_messages=None, show_hidden_initial=False, label_tag_attrs=None): 63 63 # required -- Boolean that specifies whether the field is required. 64 64 # True by default. 65 65 # widget -- A Widget class, or instance of a Widget class, that should … … 108 108 messages.update(error_messages or {}) 109 109 self.error_messages = messages 110 110 111 self.label_tag_attrs = {} 112 self.label_tag_attrs.update(label_tag_attrs or {}) 113 111 114 def clean(self, value): 112 115 """ 113 116 Validates the given value and returns its "cleaned" value as an -
django/forms/forms.py
389 389 If attrs are given, they're used as HTML attributes on the <label> tag. 390 390 """ 391 391 contents = contents or escape(self.label) 392 tag_attrs = {} 393 tag_attrs.update(self.field.label_tag_attrs) 394 tag_attrs.update(attrs or {}) 392 395 widget = self.field.widget 393 396 id_ = widget.attrs.get('id') or self.auto_id 394 397 if id_: 395 attrs = attrs and flatatt(attrs) or ''396 contents = u'<label for="%s"%s>%s</label>' % (widget.id_for_label(id_), attrs, unicode(contents))398 tag_attrs = tag_attrs and flatatt(tag_attrs) or '' 399 contents = u'<label for="%s"%s>%s</label>' % (widget.id_for_label(id_), tag_attrs, unicode(contents)) 397 400 return mark_safe(contents) 398 401 399 402 def _is_hidden(self):