Opened 7 years ago

Closed 3 years ago

#12306 closed New feature (wontfix)

Checkbox (label, field) ordering

Reported by: EoghanM Owned by: nobody
Component: Forms Version: 1.1
Severity: Normal Keywords: label checkbox BooleanField
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


It is currently very difficult to reorder the default layout of fields:

<label for="x" ...>My Label:</label> <input id="x".../>

For checkboxes, this should be either:

<input id="x".../> <label for="x"...>My Label</label>


<label><input.../> My Label</label>

At the moment, in a template there's no way of knowing if a field is a BooleanField (in order to special case the html), and I don't know how I'd edit widgets etc. to override the current layout.

This has been touched on as a sore point elsewhere:

Where would be the best place to apply a patch for this?

  • At the form level: as a new argument to forms/, called 'checkbox_row' which for e.g. table rows would look like:
    u'<tr><td colspan="2">%(field)s%(label)s%(help_text)s%(errors)s</td></tr>'
  • At the field level: as a new boolean function 'is_checkbox'?
  • Both of the above?

Change History (6)

comment:1 Changed 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

I acknowledge the problem, but I'm not sure what the solution should be.

comment:2 Changed 6 years ago by poswald

You might want to look into this Django library which allows you to override the html of any form field:

More generally, it might make sense to incorporate that library into Django itself to allow users to apply their own markup preferences. It uses the django templating system to define the html and substitutes the field values in. The application creates html5-typed input elements but it could easily be used to output html in the current html 4 style by default. Can someone on the core team can make a call as to if this approach is acceptable?

comment:3 Changed 5 years ago by mattmcc

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 3 years ago by aaugustin

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

I'm going to close this for the same reasons as #13401.

The long term solution is indeed something akin to floppyforms, but it hasn't been integrated yet due to performance concerns.

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