I try to customize my radio buttons in Django in such way:
old
<label for="id_jobStatus_1">
<span>
<a rel="jobStatus" href="#"></a>
<input type="radio" id="id_jobStatus_1" name="jobStatus" class="radio" value="1">
</span> xxx1
</label>
new
开发者_StackOverflow社区<span>
<a rel="question" href="#"></a>
<input type="radio" checked="" value="oui" name="question" id="" >
</span>
<label class="RadioObject" style="cursor: pointer;"> xxx </label>
In order to render the first one, I have already writetn a custom renderer as
class HorizRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))
However, I couldn't achieve to render the button as in second part.
Difference is, as you can see, remove the label wrapper
and put it after the input span wrapper
and add RadioObject
css class to the label.
What is the suitable way to achieve this ?
精彩评论