Opened 15 years ago
Closed 12 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 |
Description
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>
or
<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:
http://www.mail-archive.com/django-developers@googlegroups.com/msg21887.html
http://stackoverflow.com/questions/572263/
Where would be the best place to apply a patch for this?
- At the form level: as a new argument to forms/forms.py:_html_output, 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 by , 15 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 14 years ago
You might want to look into this Django library which allows you to override the html of any form field: https://github.com/brutasse/django-floppyforms
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 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:6 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → 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.
I acknowledge the problem, but I'm not sure what the solution should be.