Opened 9 years ago

Closed 9 years ago

#4785 closed (duplicate)

Widgets have nonconfigurable hardcoded HTML

Reported by: Michal Ludvig <michal@…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Widgets CheckboxSelectMultiple and RadioFieldRenderer have hardcoded <ul><li>...</li></ul> tags which makes them hard to use in a design that expects different style of output, for instance wrapping things in <div></div> tags.

Attached patch takes these <ul> and <li> tags out of the code to a class variable that can be easily overwritten in subclasses. Creating a widget DivCheckboxSelectMultiple is then as simple as:

class DivCheckboxSelectMultiple(forms.widgets.CheckboxSelectMultiple):

tags = { 'block' : u'<div>%s</div>', 'item' : u'<div><label>%(label)s %(input)s</label></div>' }

Attachments (1)

div-widgets.diff (2.3 KB) - added by Michal Ludvig <michal@…> 9 years ago.
Proposed patch

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by Michal Ludvig <michal@…>

Attachment: div-widgets.diff added

Proposed patch

comment:1 Changed 9 years ago by Chris Beaven

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

See #4592 for alternative

comment:2 Changed 9 years ago by Chris Beaven

Triage Stage: UnreviewedDesign decision needed

comment:3 Changed 9 years ago by James Bennett

Resolution: duplicate
Status: newclosed

Closing in favor of #4592.

Note: See TracTickets for help on using tickets.
Back to Top