#9473 closed (fixed)
FormWizard doesn't work with NullableBooleanField
Reported by: | LZ | Owned by: | Keith Bussell |
---|---|---|---|
Component: | contrib.formtools | Version: | 1.0 |
Severity: | Keywords: | form formwizard nullablebooleanfield | |
Cc: | Keith Bussell | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Create a series of forms. Make the first one contain a NullableBooleanField. Then, place the forms in a (contrib.formtools.) Wizard.
If the user set the value of the field to "True", it will succeed on the first submit. However, when there is a second submit, it will fail with a cryptic Exception message. It turns out that there's a render_hash_failure.
This is my first time trying Django, so I only have a few hours experience, but I think the problem comes from
http://code.djangoproject.com/browser/django/trunk/django/contrib/formtools/utils.py :
19 data = [(bf.name, bf.field.clean(bf.data) or ) for bf in form]
Thank you!
Attachments (2)
Change History (17)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
I debugged this further. It turns out what widgets.NullBooleanSelect.value_from_datadict(self, data, files, name) needs to accept the 'True' and 'False' string values in addition to the True and False boolean values.
comment:4 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 16 years ago
This is similar to #9336, which describes a similar problem for CheckboxInput
comment:6 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 16 years ago
Cc: | added |
---|---|
Has patch: | set |
I applied the change suggested by LZ and added a test.
comment:8 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:9 by , 16 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
Actually, maybe you can pull the info you need out of the context instead of using that regex. Take a look; I'm bumping this back out of rfc.
comment:10 by , 16 years ago
This isn't really a bug in FormWizard. I don't think the regression tests have to involve it at all; you can just test the widget/field directly. See patch on #9336
comment:11 by , 16 years ago
fix_9473_2.diff updates the test to use the previous_fields
context member instead of parsing the whole html response. Also broke up the test function a bit to make it more reusable for other tests in the future.
comment:12 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:13 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I meant NullBooleanField, BTW. Sorry for the error.