Opened 10 years ago
Closed 10 years ago
#25495 closed New feature (wontfix)
CheckboxSelectMultiple cannot set CSS class of UL
| Reported by: | Tom van Dijk | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | 1.7 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
It would be nice to be able to override (or actually: set) the class of the <ul> tag of a CheckboxSelectMultiple.
Attributes of this tag cannot be set at the moment.
Example code that I now use to "hack" the class into the <ul>. The example code is used in the context of mezzanine/grappelli, which provides a nice CSS with ul.checkboxlist that works well for admin pages.
class CheckboxSelectMultipleRenderer(CheckboxFieldRenderer):
def render(self):
result = super(CheckboxSelectMultipleRenderer, self).render()
return mark_safe(re.sub("<ul id", '<ul class="checkboxlist" id', result, count=1))
class CheckboxSelectMultipleCss(CheckboxSelectMultiple):
renderer = CheckboxSelectMultipleRenderer
Change History (2)
comment:1 by , 10 years ago
| Easy pickings: | unset |
|---|
comment:2 by , 10 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
Feel free to reopen if you feel that other ticket doesn't offer a good solution to this issue and you have an alternate proposal for what the API could look like.
I guess template-based widget rendering would add some flexibility here (#15667). That feature is expected in Django 1.10. Do you think that would meet your use case?