#22533: Allow overriding `label_suffix` on a per-field basis
-------------------------------+--------------------
     Reporter:  julen          |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Forms          |    Version:  1.6
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 Django 1.6 onwards, `BoundField.label_tag` now includes form's
 `label_suffix`.

 The docs mention that ''"You can also customize the `label_suffix` on a
 per-field basis using the new `label_suffix` parameter on
 `label_tag()`"''.

 In order to customize this on a per-field basis, you'd use `{{
 field|label_tag:"=" }}` from templates, where `label_tag` is a custom
 template filter which would return `field.label_tag(label_suffix='=')` for
 this example.

 Since this is not an attribute stored by each field, you can only override
 it if you are manually rendering fields. This is not convenient if you are
 using other shortcuts such as `{{ form.as_p }}` — there's no way you can
 override the `label_suffix` on a per-field basis in that scenario.

 I'd suggest to store `label_suffix` for each field, so it could be set
 when you instantiate the field as part of a form. `BoundField.label_tag`
 would then be able to be properly customized on a per-field basis. It
 would use:
 1. `label_suffix` from the keyword arguments, specified at run-time. If
 this is `None`,
 2. `self.label_suffix`, defined when adding the field to a form. If this
 is `None`,
 3. `self.form.label_suffix`, defined when instantiating the form.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22533>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.2224b363094d289ec990671273026d95%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to