Re: [Django] #34034: Adding a class on ChoiceWidget subwidgets is excessively difficult (was: Adding a class on ChoiceWidget subwidgets is excessingly difficult)

10 views
Skip to first unread message

Django

unread,
Sep 28, 2022, 5:58:08 AM9/28/22
to django-...@googlegroups.com
#34034: Adding a class on ChoiceWidget subwidgets is excessively difficult
------------------------------+------------------------------------
Reporter: Claude Paroz | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Hey Claude,

> Maybe adding `option_attrs`…

So I'm looking at this in `ChoiceWidget`:

{{{
def create_option(
self, name, value, label, selected, index, subindex=None,
attrs=None
):
...
option_attrs = (
self.build_attrs(self.attrs, attrs) if
self.option_inherits_attrs else {}
)
...
}}}

Do you think pulling that into a property (that could then be overridden)
would be sufficient? Maybe the `else` would pull from an `__init__` arg. …
🤔

(Implementation TBD)

Seems a reasonable suggestion anyhow. Thanks.

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

Reply all
Reply to author
Forward
0 new messages