Opened 10 years ago

Closed 9 years ago

#3313 closed defect (wontfix)

decouple BoundField from BaseForm._html_output

Reported by: gustavo.torrico@… Owned by: adrian
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: UI/UX:



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) (553 bytes) - added by gustavo.torrico@… 10 years ago. (558 bytes) - added by gustavo.torrico@… 10 years ago.
ticket-3313.diff (510 bytes) - added by mir@… 10 years ago.
second path with full path

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by gustavo.torrico@…

Changed 10 years ago by gustavo.torrico@…

comment:1 Changed 10 years ago by gustavo.torrico@…

sorry forgot self in front of __getitem__}

comment:2 Changed 10 years ago by mir@…

  • Has patch set
  • Needs documentation set
  • Needs tests set
  • Triage Stage changed from Unreviewed to Design decision needed

Changed 10 years ago by mir@…

second path with full path

comment:3 Changed 9 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to 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.

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