Code

Opened 5 years ago

Closed 16 months 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?

Attachments (0)

Change History (6)

comment:1 Changed 4 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 3 years ago by poswald

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 Changed 3 years ago by mattmcc

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:6 Changed 16 months 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.