Created
March 9, 2012 17:31
-
-
Save spookylukey/2007671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.utils.safestring import mark_safe | |
from django.utils.encoding import force_unicode | |
class BootstrapRadioFieldRenderer(forms.RadioSelect.renderer): | |
def render(self): | |
"""Outputs a <ul> for this set of radio fields.""" | |
return mark_safe('<span id="id_%s"></span>' | |
'<ul class="inputs-list">\n%s\n</ul>' | |
% (self.name, | |
u'\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))) | |
class BootstrapRadioSelect(forms.RadioSelect): | |
""" | |
RadioSelect with the inputs-list class, to match bootstrap style | |
""" | |
renderer = BootstrapRadioFieldRenderer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment