Django

Code

Show
Ignore:
Timestamp:
09/18/08 02:16:08 (2 months ago)
Author:
mtredinnick
Message:

Fixed #9125 -- When displaying errors for a form with only hidden fields, make sure the resulting XHTML is correct.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/regressiontests/forms/regressions.py

    r8761 r9067  
    8989>>> f.cleaned_data 
    9090{'data': u'xyzzy'} 
     91 
     92A form with *only* hidden fields that has errors is going to be very unusual. 
     93But we can try to make sure it doesn't generate invalid XHTML. In this case, 
     94the as_p() method is the tricky one, since error lists cannot be nested 
     95(validly) inside p elements. 
     96 
     97>>> class HiddenForm(Form): 
     98...     data = IntegerField(widget=HiddenInput) 
     99>>> f = HiddenForm({}) 
     100>>> f.as_p() 
     101u'<ul class="errorlist"><li>(Hidden field data) This field is required.</li></ul>\n<p> <input type="hidden" name="data" id="id_data" /></p>' 
     102>>> f.as_table() 
     103u'<tr><td colspan="2"><ul class="errorlist"><li>(Hidden field data) This field is required.</li></ul><input type="hidden" name="data" id="id_data" /></td></tr>' 
     104 
    91105"""