I propose to add a Horizontal radio selection render that is similar to
{{{
from django.utils.safestring import mark_safe
class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self):
return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))
class ApprovalForm(forms.Form):
approval = forms.ChoiceField(choices=APPROVAL_CHOICES,
initial=0,
widget=forms.RadioSelect(renderer=HorizontalRadioRenderer),
)
}}}
This could as solve ticket #28059.
PS. The code for `HorizontalRadioRenderer` seems to be a folklore on the
internet for years, it can be found on
*[http://stackoverflow.com/questions/5935546/align-radio-buttons-
horizontally-in-django-forms stackoverflow] and
*[https://wikis.utexas.edu/display/~bm6432/Django-
Modifying+RadioSelect+Widget+to+have+horizontal+buttons UTexas Wiki].
--
Ticket URL: <https://code.djangoproject.com/ticket/28060>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Musen
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/28060#comment:1>
* needs_docs: 0 => 1
* version: 1.11 => master
* component: Uncategorized => Forms
* needs_tests: 0 => 1
* type: Uncategorized => New feature
--
Ticket URL: <https://code.djangoproject.com/ticket/28060#comment:2>
Comment (by Simon Charette):
Isn't this something that can be achieved by styling the list elements to
be displayed horizontally instead?
Just wanted to say I don't think that stripping all the markup is the way
to go here.
--
Ticket URL: <https://code.djangoproject.com/ticket/28060#comment:3>
* status: assigned => closed
* resolution: => wontfix
Comment:
I think #28059 will be fixed by restoring the CSS classes on the `<ul>`
that were there before 1.11. Presumably the same solution could be used in
other apps. The code in the ticket description no longer words after the
introduction of template-based widget rendering in Django 1.11.
--
Ticket URL: <https://code.djangoproject.com/ticket/28060#comment:4>