Opened 17 years ago

Closed 17 years ago

#4975 closed (fixed)

Colons: Always appended to labels

Reported by: rtconner Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: newforms forms
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

Hi, I wanted to make a form, but I didn't want the labels to have colons. After some looking I figured I'd have to make myself a generator. But after looking, even making my own generator does not get rid of the colons. My own generator would use _html_output which always appends colons (except where there is punctuation).

That is not very flexible. Can you move the colons into as_table, as_ul, so they can be made to be optional. Or perhaps make some label formatting function within BaseForm which I can override when I would want to.

Thanks. And yes Django still rocks.

Attachments (2)

label_colon_removal.patch (90.3 KB ) - added by Vincent Foley 17 years ago.
configurable_suffix.patch (5.4 KB ) - added by Vincent Foley 17 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by anonymous, 17 years ago

I was thinking, another way to do this is to make a labelSuffix attribute on BaseForm. By default the value could be a colon. If its set to None there would be no colon appended. If I changed it to a dash a dash would be appended.

comment:2 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign decision needed

It's come up before and the answer has been "don't use _html_output", but I think that perhaps there's a place for a label_tag_func function on BaseForm.

It would also allow for things like building a label which says "Email (optional):"

The default func would look something like:

def label_tag_func(bf):
    label = escape(force_unicode(bf.label))
    # Only add a colon if the label does not end in punctuation.
    if label[-1] not in ':?.!':
        label += ':'
    return label

by Vincent Foley, 17 years ago

Attachment: label_colon_removal.patch added

comment:3 by Vincent Foley, 17 years ago

Has patch: set

I've added a (rather large) patch to fix the issue. The patch remove the code that adds the colon from forms.py and the rest of the patch is to fix the test cases.

comment:4 by Malcolm Tredinnick, 17 years ago

Removing the default colon is not an option. Making it configurable (whether or not to include it) is a possibility, though.

comment:5 by Vincent Foley, 17 years ago

I reworked the issue and I have developed a patch to make it possible to configure the suffix character on a per-form basis.

by Vincent Foley, 17 years ago

Attachment: configurable_suffix.patch added

comment:6 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [6352]) Fixed #4975 -- Allow the default label suffix character to be configured. Thanks, Vincent Foley.

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