#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)
Change History (8)
by , 17 years ago
Attachment: | data_prefix_dict.diff added |
---|
by , 17 years ago
Attachment: | field_testcase.py added |
---|
Testcase that fails on current trunk, passes with patch applied.
comment:1 by , 17 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
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 , 16 years ago
milestone: | → 1.0 |
---|
comment:3 by , 16 years ago
Keywords: | forms added; newforms removed |
---|---|
Owner: | changed from | to
comment:4 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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')
The patch that solves this particular problem (lets the test case not fail).