Opened 8 years ago

Closed 8 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:

Description

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@…> 8 years ago.
Proposed patch

Download all attachments as: .zip

Change History (4)

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

Proposed patch

comment:1 Changed 8 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

See #4592 for alternative

comment:2 Changed 8 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 8 years ago by ubernostrum

  • Resolution set to duplicate
  • Status changed from new to closed

Closing in favor of #4592.

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