Opened 9 years ago

Closed 9 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 Tim Graham, 9 years ago

Easy pickings: unset

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?

comment:2 by Tim Graham, 9 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top