# HG changeset patch
# Parent 898f33efebdafb0a13ab8b69dc3b835ab2da9c0e
diff --git a/tests/regressiontests/forms/formsets.py b/tests/regressiontests/forms/formsets.py
a
|
b
|
|
308 | 308 | |
309 | 309 | If we fill a form with something and then we check the can_delete checkbox for |
310 | 310 | that form, that form's errors should not make the entire formset invalid since |
311 | | it's going to be deleted. |
| 311 | it's going to be deleted. Some forms are invalid so we cannot use cleaned_data. |
312 | 312 | |
313 | 313 | >>> class CheckForm(Form): |
314 | 314 | ... field = IntegerField(min_value=100) |
… |
… |
|
328 | 328 | >>> formset = CheckFormSet(data, prefix='check') |
329 | 329 | >>> formset.is_valid() |
330 | 330 | True |
| 331 | >>> [form.cleaned_data for form in formset.forms] |
| 332 | Traceback (most recent call last): |
| 333 | ... |
| 334 | AttributeError: 'CheckForm' object has no attribute 'cleaned_data' |
331 | 335 | |
332 | 336 | If we remove the deletion flag now we will have our validation back. |
333 | 337 | |
… |
… |
|
517 | 521 | [{'votes': 900, 'DELETE': True, 'ORDER': 2, 'choice': u'Fergie'}] |
518 | 522 | |
519 | 523 | Should be able to get ordered forms from a valid formset even if a |
520 | | deleted form would have been invalid. |
| 524 | deleted form would have been invalid and without cleaned_data. |
521 | 525 | |
522 | 526 | >>> class Person(Form): |
523 | 527 | ... name = CharField() |
… |
… |
|
529 | 533 | |
530 | 534 | >>> p = PeopleForm( |
531 | 535 | ... {'form-0-name': u'', 'form-0-DELETE': u'on', # no name! |
532 | | ... 'form-TOTAL_FORMS': 1, 'form-INITIAL_FORMS': 1, |
533 | | ... 'form-MAX_NUM_FORMS': 1}) |
| 536 | ... 'form-1-name': u'John Smith', 'form-1-DELETE': u'', |
| 537 | ... 'form-TOTAL_FORMS': 2, 'form-INITIAL_FORMS': 2, |
| 538 | ... 'form-MAX_NUM_FORMS': 2}) |
534 | 539 | |
535 | 540 | >>> p.is_valid() |
536 | 541 | True |
537 | | >>> p.ordered_forms |
538 | | [] |
| 542 | >>> for form in p.ordered_forms: |
| 543 | ... print form.cleaned_data |
| 544 | {'DELETE': False, 'name': u'John Smith', 'ORDER': None} |
| 545 | >>> [form.cleaned_data for form in p.forms] |
| 546 | Traceback (most recent call last): |
| 547 | ... |
| 548 | AttributeError: 'Person' object has no attribute 'cleaned_data' |
539 | 549 | |
540 | 550 | # FormSet clean hook ########################################################## |
541 | 551 | |