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 /docs/ref/forms/api.txt | |
| 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 'docs/ref/forms/api.txt')
| -rw-r--r-- | docs/ref/forms/api.txt | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 8a5303710a..950bd3a088 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -652,8 +652,13 @@ Note that the label suffix is added only if the last character of the label isn't a punctuation character (in English, those are ``.``, ``!``, ``?`` or ``:``). -You can also customize the ``label_suffix`` on a per-field basis using the -``label_suffix`` parameter to :meth:`~django.forms.BoundField.label_tag`. +.. versionadded:: 1.8 + +Fields can also define their own :attr:`~django.forms.Field.label_suffix`. +This will take precedence over :attr:`Form.label_suffix +<django.forms.Form.label_suffix>`. The suffix can also be overridden at runtime +using the ``label_suffix`` parameter to +:meth:`~django.forms.BoundField.label_tag`. Notes on field ordering ~~~~~~~~~~~~~~~~~~~~~~~ @@ -799,12 +804,12 @@ auto-generated label tag. An optional ``attrs`` dictionary may contain additional attributes for the ``<label>`` tag. The HTML that's generated includes the form's -:attr:`~django.forms.Form.label_suffix` (a colon, by default). The optional -``label_suffix`` parameter allows you to override the form's -:attr:`~django.forms.Form.label_suffix`. For example, you can use an empty -string to hide the label on selected fields. If you need to do this in a -template, you could write a custom filter to allow passing parameters to -``label_tag``. +:attr:`~django.forms.Form.label_suffix` (a colon, by default) or, if set, the +current field's :attr:`~django.forms.Field.label_suffix`. The optional +``label_suffix`` parameter allows you to override any previously set +suffix. For example, you can use an empty string to hide the label on selected +fields. If you need to do this in a template, you could write a custom +filter to allow passing parameters to ``label_tag``. .. versionchanged:: 1.8 |
