#9125: as_p() produces wrong output sometimes
-------------------------------+--------------------------------------------
Reporter: kratorius | Owner: kratorius
Status: new | Milestone:
Component: Forms | Version: 1.0
Keywords: as_p, form, forms | Stage: Unreviewed
Has_patch: 0 |
-------------------------------+--------------------------------------------
While investigating on #8720 I ran into the following issue. Consider the
following view:
{{{
#!python
from django.template import Context, Template
from django.http import HttpResponse
from django import forms
class TestForm(forms.Form):
initial_data = [1,2,3,4]
testfield = forms.MultipleChoiceField(initial=initial_data,
required=False, widget=forms.MultipleHiddenInput())
def tform(request):
if request.method == 'POST':
form = TestForm(request.POST)
else:
form = TestForm()
t = Template('<html><body><form action="." method="POST">{{ form.as_p
}}<input type="submit" /></form></body></html>')
c = Context({ 'form' : form })
return HttpResponse(t.render(c))
}}}
If you submit the form you'll get the following output:
{{{
<html><body>
<form action="." method="POST">
<ul class="errorlist">
<li>(Hidden field testfield) Select a valid choice. 1 is not one of the
available choices.</li>
<<input type="hidden" name="testfield" value="1" id="id_testfield" />
<input type="hidden" name="testfield" value="2" id="id_testfield" />
<input type="hidden" name="testfield" value="3" id="id_testfield" />
<input type="hidden" name="testfield" value="4" id="id_testfield" /></p>
<input type="submit" /></form></body></html>
}}}
Notice the missing {{{<p>}}} tag after the error line.
I tried with {{{as_table}}} and {{{as_ul}}} as well, and they render the
form correctly.
--
Ticket URL: <http://code.djangoproject.com/ticket/9125>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---