Opened 19 years ago
Closed 19 years ago
#3193 closed defect (fixed)
[patch] modify as_hidden() to handle MultipleChoiceField correctly
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | normal | Keywords: | as_hidden MultipleChoiceField |
| Cc: | Honza.Kral@… | Triage Stage: | Unreviewed |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
It is a quick and dirty patch (works though ;) ), but since the information on what field requires list as value is gone, I had to use the Field class to identify the correct value. I don't like the idea of checking for Field;s class every time I render a hidden field, but it was the best I could do without going further into the code.
The added widget class renders multiple <input type="hidden" .. > tags (one for every checked option).
I will be glad for any feedback and/or comments.
Attachments (1)
Change History (4)
by , 19 years ago
| Attachment: | multi_hidden.patch added |
|---|
comment:1 by , 19 years ago
Hmmm, yeah, doing an isinstance there seems a bit inelegant. I'll play around with some other implementations... Maybe it's as easy as giving the Field class a hidden_field attribute, which MultipleChoiceField would override.
comment:2 by , 19 years ago
I originally thought of using the requires_list field, but it was no longer there so I decided not to add another field with roughly the same meaning...
btw. it seems more natural to me for as_hidden, as_text etc to be handled by Field and not BoundField - the latter knows nothing about the data (as demonstrated in this problem) and therefore cannot adapt its behaviour, the Field seems better suited for this.
comment:3 by , 19 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
implementation of MultipleHiddenInput