Opened 19 years ago
Closed 19 years ago
#3313 closed defect (wontfix)
decouple BoundField from BaseForm._html_output
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| Component: | Forms | Version: | |
| Severity: | normal | Keywords: | BoundField, BaseForm, newforms |
| Cc: | Triage Stage: | Design decision needed | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
As mentioned in *this message, the preferred way to mark fields required would be to use CSS. From what I can see, the simplest way to do this would be to allow the user to override the label_tag function in
BoundField. Doing this, however, would necessitate having to rewrite the entire _html_output function inBaseForm.
In order to avoid this, I propose having that function call BaseForm.__get_item__ so that if you wanted to generate your own customized label tags, you would only need to override BaseForm.__get_item__ and BoundField.label_tag (smaller changes than BaseForm._html_output)
Attachments (3)
Change History (6)
by , 19 years ago
| Attachment: | forms.py.diff added |
|---|
by , 19 years ago
| Attachment: | forms.py.diff2 added |
|---|
comment:1 by , 19 years ago
comment:2 by , 19 years ago
| Has patch: | set |
|---|---|
| Needs documentation: | set |
| Needs tests: | set |
| Triage Stage: | Unreviewed → Design decision needed |
comment:3 by , 19 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
There's a problem with this patch -- BoundField appears more than once in the implementation of Form, so being able to override __getitem__ wouldn't catch the other appearance. (Specifically, you'd have to override __iter__ too.
But even that strikes me as a bit strange. What you really want is to specify the class of BoundField to use. I played with adding a bound_field_class argument to BaseForm, but that's obscure. This whole thing smells like the wrong solution for your problem, which is that you want to display a custom CSS around <label> elements in your form. Let's come at it a different way. If you have any ideas, please open a new ticket with suggestions.
sorry forgot
selfin front of__getitem__}