Opened 18 years ago

Closed 17 years ago

#3649 closed (duplicate)

Better formatting of the label text in newforms

Reported by: Henrik Vendelbo <info@…> Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: label output
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The current label text processing is quite hardcoded, and changing it requires patching forms.py or replacing it.

The default behaviour is to use a prettified version of the field name if no label is given and html_escape it, and append a ':'.

This behaviour is retained, but can be changed by supplying two functions to the Form constructor.

Attachments (1)

forms_label_formatting.diff (972 bytes ) - added by info@… 18 years ago.
Changes to newforms forms.py

Download all attachments as: .zip

Change History (5)

by info@…, 18 years ago

Attachment: forms_label_formatting.diff added

Changes to newforms forms.py

comment:1 by info@…, 18 years ago

I forgot to change the escape_label function to include the field as a parameter. This allows highlighting labels for required fields, which is quite common.

comment:2 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:3 by anonymous, 18 years ago

It would also be good to move the loop from the internal formatting function to the as_... functions, so it is possible to easily make custom renderers that print a subset of fields.

comment:4 by James Bennett, 17 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #4975, which was fixed in [6352]; the label suffix is now configurable.

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