Permalink
Browse files

Merge pull request #47 from Nivl/master

Link labels with their field
  • Loading branch information...
2 parents a1b3f50 + 2b88eea commit 3a7b0ec655d9768a9896779c2785101e31117754 @earle earle committed Apr 9, 2012
View
@@ -63,7 +63,7 @@ def render_fields(self, fields, separator=u""):
""" Render a list of fields and join the fields by the value in separator. """
output = []
-
+
for field in fields:
if isinstance(field, Fieldset):
output.append(field.as_html(self))
@@ -126,15 +126,16 @@ def render_field(self, field):
'bf_raw' : bf,
'errors' : mark_safe(bf_errors),
'field_type' : mark_safe(field.__class__.__name__),
+ 'label_id': bf._auto_id(),
}
-
+
if self.custom_fields.has_key(field):
template = get_template(self.custom_fields[field])
else:
template = select_template([
os.path.join(self.template_base, 'field_%s.html' % type(field_instance.widget).__name__.lower()),
os.path.join(self.template_base, 'field_default.html'), ])
-
+
# Finally render the field
output = template.render(Context(field_hash))
@@ -160,8 +161,8 @@ def __init__(self, legend, *fields, **kwargs):
self.legend_html = legend and ('<legend>%s</legend>' % legend) or ''
self.fields = fields
self.css_class = kwargs.get('css_class')
-
+
def as_html(self, form):
class_str = self.css_class and (' class="%s"' % self.css_class) or ''
return u'<fieldset%s>%s%s</fieldset>' % (class_str, self.legend_html, form.render_fields(self.fields), )
-
+
@@ -1,5 +1,5 @@
<div class="control-group input-append{% if errors %} error{% endif %}">
- <label class="control-label">{{ label }}</label>
+ <label class="control-label" for="{{ label_id }}">{{ label }}</label>
<div class="controls">
{{ bf }}
{% if errors %}
@@ -1,5 +1,5 @@
<div class="control-group{% if errors %} error{% endif %}">
- <label class="control-label">{{ label }}</label>
+ <label class="control-label" for="{{ label_id }}">{{ label }}</label>
<div class="controls">
{{ bf }}
{% if errors %}

0 comments on commit 3a7b0ec

Please sign in to comment.