Skip to content

Commit

Permalink
Added support for radio select lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
doreilly committed Dec 20, 2011
1 parent 5518ac1 commit 27cc0a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bootstrapform/templates/bootstrapform/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,19 @@
{% else %}
{{ field.label_tag }}
<div class="input">
{{ field }}

{% if field|is_radio %}
<ul class="inputs-list">
{% for radio in field %}
<li>
<label>
{{ radio.tag }} <span>{{ radio.choice_label }}</span>
</label>
</li>
{% endfor %}
</ul>
{% else %}
{{ field }}
{% endif %}
{% for error in field.errors %}
<span class="help-inline">{{ error }}</span>
{% endfor %}
Expand Down
5 changes: 5 additions & 0 deletions bootstrapform/templatetags/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ def bootstrap(form):
@register.filter
def is_checkbox(field):
return field.field.widget.__class__.__name__.lower() == "checkboxinput"

@register.filter
def is_radio(field):
return field.field.widget.__class__.__name__.lower() == 'radioselect'

0 comments on commit 27cc0a9

Please sign in to comment.