Opened 18 years ago

Closed 18 years ago

#3313 closed defect (wontfix)

decouple BoundField from BaseForm._html_output

Reported by: gustavo.torrico@… 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

*newforms.forms

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 in BaseForm.

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)

forms.py.diff (553 bytes ) - added by gustavo.torrico@… 18 years ago.
forms.py.diff2 (558 bytes ) - added by gustavo.torrico@… 18 years ago.
ticket-3313.diff (510 bytes ) - added by mir@… 18 years ago.
second path with full path

Download all attachments as: .zip

Change History (6)

by gustavo.torrico@…, 18 years ago

Attachment: forms.py.diff added

by gustavo.torrico@…, 18 years ago

Attachment: forms.py.diff2 added

comment:1 by gustavo.torrico@…, 18 years ago

sorry forgot self in front of __getitem__}

comment:2 by mir@…, 18 years ago

Has patch: set
Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedDesign decision needed

by mir@…, 18 years ago

Attachment: ticket-3313.diff added

second path with full path

comment:3 by Adrian Holovaty, 18 years ago

Resolution: wontfix
Status: newclosed

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.

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