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