Opened 16 years ago

Closed 16 years ago

Last modified 12 years ago

#6733 closed (invalid)

Selected not rendered for SelectMultiple when prefix is present

Reported by: Adam Gomaa Owned by: Ivan Giuliani
Component: Forms Version: dev
Severity: Keywords: forms
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

See the testcase with the problem here. I have attached the diff that fixes the problem for me, but it breaks other widgets (regressiontests.forms.tests.__test__.form_tests fails), and it's not really clear to me how to fix it or really what the root cause is. Either way, hopefully it's a starting point for someone who understands the internals of newforms better than myself...

Attachments (2)

data_prefix_dict.diff (573 bytes ) - added by Adam Gomaa 16 years ago.
The patch that solves this particular problem (lets the test case not fail).
field_testcase.py (400 bytes ) - added by Adam Gomaa 16 years ago.
Testcase that fails on current trunk, passes with patch applied.

Download all attachments as: .zip

Change History (8)

by Adam Gomaa, 16 years ago

Attachment: data_prefix_dict.diff added

The patch that solves this particular problem (lets the test case not fail).

by Adam Gomaa, 16 years ago

Attachment: field_testcase.py added

Testcase that fails on current trunk, passes with patch applied.

comment:1 by Jacob, 16 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Looks good. A proper patch with the testcase and the fix all in a single diff would be extremely helpful to whoever applies this.

comment:2 by Matt McClanahan, 16 years ago

milestone: 1.0

comment:3 by Ivan Giuliani, 16 years ago

Keywords: forms added; newforms removed
Owner: changed from nobody to Ivan Giuliani

comment:4 by Ivan Giuliani, 16 years ago

Resolution: invalid
Status: newclosed

This ticket is invalid. You need to specify the prefix when passing data to the form. The provided test case (slightly modified version):

CHOICES=[(1, 'one'), (2, 'two')]

class TestForm(forms.Form):
    number = forms.MultipleChoiceField(choices=CHOICES, required=False)

data = { 'number': 1 }
foo = TestForm(data, prefix='mypre')

should be:

CHOICES=[(1, 'one'), (2, 'two')]

class TestForm(forms.Form):
    number = forms.MultipleChoiceField(choices=CHOICES, required=False)

data = { 'mypre-number': 1 }
foo = TestForm(data, prefix='mypre')

comment:5 by Ivan Giuliani, 16 years ago

(the attribute's value in data in the examples should be [1], not 1)

comment:6 by Jacob, 12 years ago

milestone: 1.0

Milestone 1.0 deleted

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