Opened 16 years ago

Last modified 13 years ago

#8171 closed

Invalid formset when form is missing from POST data — at Initial Version

Reported by: James Chua <james_027@…> Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: formsets
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A forms that doesn't have ordered prefix will not be process. On the sample the formset is expecting to process choices-0, choices-1, and choices-2 forms while choices-4, and choices-5 forms will be ignore but it should be process because the 3 forms we are referring here are the choices-0, choices-4, choices-5 and it should return False on formset.is_valid() since the choices-4 is invalid while choices-5 is considered valid since it is blank. As a result the formset is valid because it treats blank forms as valid which are choices-1 and choices-2.

data = {

... 'choices-TOTAL_FORMS': '3', # the number of forms rendered
... 'choices-INITIAL_FORMS': '0', # the number of forms with initial data
... 'choices-0-choice': 'Calexico',
... 'choices-0-votes': '100',
... 'choices-4-choice': 'The Decemberists',
... 'choices-4-votes': , # missing value
... 'choices-5-choice':
,
... 'choices-5-votes': ,
... }

formset = ChoiceFormSet(data, auto_id=False, prefix='choices')
formset.is_valid()

True

Change History (0)

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