Django

Code

Ticket #4975 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Colons: Always appended to labels

Reported by: rtconner Assigned to: nobody
Milestone: Component: Forms
Version: SVN Keywords: newforms forms
Cc: Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

label_colon_removal.patch (90.3 kB) - added by gnuvince on 09/15/07 21:10:11.
configurable_suffix.patch (5.4 kB) - added by gnuvince on 09/15/07 23:19:03.

Change History

07/26/07 11:00:08 changed by anonymous

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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.

08/01/07 00:32:46 changed by SmileyChris

  • stage changed from Unreviewed to Design 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

09/15/07 21:10:11 changed by gnuvince

  • attachment label_colon_removal.patch added.

09/15/07 21:12:03 changed by gnuvince

  • has_patch set to 1.

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.

09/15/07 21:15:12 changed by mtredinnick

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

09/15/07 22:13:32 changed by gnuvince

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

09/15/07 23:19:03 changed by gnuvince

  • attachment configurable_suffix.patch added.

09/15/07 23:38:20 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #4975 (Colons: Always appended to labels)




Change Properties
Action