Opened 7 years ago

Closed 4 years ago

#6920 closed Bug (wontfix)

FormWizard processing a DateField using SelectDateWidget results in hash mismatch

Reported by: kgrandis Owned by: nobody
Component: contrib.formtools Version: master
Severity: Normal Keywords: FormWizard, SelectDateWidget
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

FormWizard seems to handle DateFields just fine if you use the default text field widget. However, using SelectDateWidget within the same DateField causes the following error message: "We apologize, but your form has expired. Please continue filling out the form from this page." This message is generated when the hash codes for previously filled and validated form do not match the POSTed HiddenInput hashes.

Could this have something to do with SelectDateWidget returning a datetime.date, which is later rendered into a string?

Replication:
Follow Django's FormWizard example ( http://www.djangoproject.com/documentation/form_wizard/ )

Modify !ContactForm1 to include an event_date. This works with the default DateField

class ContactForm1(forms.Form):
    subject = forms.CharField(max_length=100)
    sender = forms.EmailField()
    event_date = forms.DateField()

Adding the SelectDateWidget results in the hash mismatch after completing !ContactForm2.

class ContactForm1(forms.Form):
    subject = forms.CharField(max_length=100)
    sender = forms.EmailField()
    event_date = forms.DateField(widget=SelectDateWidget())

Attachments (1)

0001-Added-working-hidden_widget-to-MultiValueField-692.patch (1.9 KB) - added by sebastian_noack 7 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 in reply to: ↑ description Changed 7 years ago by fedor <name.zh@…>

Replying to kgrandis:
The same problem is encountered when using CheckboxSelectMultiple widget.

comment:2 Changed 7 years ago by sebastian_noack

I noted the same problem when using MultiValueField and MultiWidget. But I fixed it with the attached patch.

The problem was, that the HiddenInput used as hidden_widget by the MultiValueField, renders the multiple values as string representation of a Python list. I added a patch, which is using a MultiWidget containing the hidden_widget of the nested fields as MultiValueField's hidden_widget which works fine with the FormWizard.

comment:3 Changed 7 years ago by ElliottM

Wher are you getting the SelectDateWidget from?

comment:4 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:6 Changed 4 years ago by jezdez

  • Easy pickings unset
  • Resolution set to wontfix
  • Status changed from new to closed
  • UI/UX unset

This is about the old FormWizard which has been refactored by using class based views.

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