Opened 3 years ago
Closed 3 years ago
#33226 closed Uncategorized (duplicate)
Add css class hooks to BaseForm
Reported by: | David Smith | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 3.2 |
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
Form
has a couple of hooks to add classes to a form. See docs.
However, the `BaseForm` does not have a class level initialisation of these. The classes are then later added via a hasattr
check.
I was wondering if class level defaults (None
) should be added for these to make them more discovarable, also the hasattr
logic can just be replaced with Form.required_css_class
Note:
See TracTickets
for help on using tickets.
Hey David, this is a duplicate of #14322.
Possibly that's worth re-opening (via a discussion, following triage guidelines for wontfix tickets) — auto-complete and type checkers much prefer attributes to be defined (as
None
?) rather than injected later.I recall we've closed similar proposals along these lines though; often the references are able to remain entirely within the injecting code, whereas if they're declared (suddenly) they're split over multiple files. (e.g. excluding usages,
required_css_class
appears only inboundfield.py
) — we didn't want to litter class definitions and/or init methods withNone
declarations. (Better the tooling gets cleverer.)Also #14322 (and #3512) were concerned about backwards compatibility. The specific issue there may not apply after all this time, but it needs a thought.