diff options
| author | Julen Ruiz Aizpuru <julenx@gmail.com> | 2014-04-29 10:07:57 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-05-13 09:09:33 -0400 |
| commit | 5eb81ce44532596ecc1c781d93f3421a467a6206 (patch) | |
| tree | 82eea7c4de4c46f62e46220aec97c59572931cf2 /django/forms/forms.py | |
| parent | f2a8e47cfd75f6135634a833f0a6a621909b4c3a (diff) | |
Fixed #22533 -- Added label_suffix parameter to form fields.
Fields can now receive the `label_suffix` attribute, which will override
a form's `label_suffix`.
This enhances the possibility to customize form's `label_suffix`, allowing
to use such customizations while using shortcuts such as
`{{ form.as_p }}`.
Note that the field's own customization can be overridden at runtime by
using the `label_prefix` parameter to `BoundField.label_tag()`.
Refs #18134.
Diffstat (limited to 'django/forms/forms.py')
| -rw-r--r-- | django/forms/forms.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py index f248d08726..f868165977 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -616,8 +616,10 @@ class BoundField(object): label_suffix allows overriding the form's label_suffix. """ contents = contents or self.label + if label_suffix is None: + label_suffix = (self.field.label_suffix if self.field.label_suffix is not None + else self.form.label_suffix) # Only add the suffix if the label does not end in punctuation. - label_suffix = label_suffix if label_suffix is not None else self.form.label_suffix # Translators: If found as last label character, these punctuation # characters will prevent the default label_suffix to be appended to the label if label_suffix and contents and contents[-1] not in _(':?.!'): |
