Opened 18 years ago

Closed 18 years ago

#3193 closed defect (fixed)

[patch] modify as_hidden() to handle MultipleChoiceField correctly

Reported by: Honza Král <Honza.Kral@…> 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)

multi_hidden.patch (1.9 KB ) - added by Honza Král <Honza.Kral@…> 18 years ago.
implementation of MultipleHiddenInput

Download all attachments as: .zip

Change History (4)

by Honza Král <Honza.Kral@…>, 18 years ago

Attachment: multi_hidden.patch added

implementation of MultipleHiddenInput

comment:1 by Adrian Holovaty, 18 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 Honza Král <Honza.Kral@…>, 18 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 Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

(In [4298]) Fixed #3193 -- newforms: Modified as_hidden() to handle MultipleChoiceField correctly. Thanks for the report, Honza Kral

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