Friday, July 30, 2010

Form Validation

I'm trying to use this line of code in form validation, and it is not
working:

{{ form.field_name.errors }}


The following lines do output:
{{ form.filed_name}}
{{ form.field_name.help_text }}

Any thoughts? Could it be something in the view?

Here is the index.html page:
#############################################################################
{% extends "feedback/base.html" %}


{% block content %}


<div id="survey-form">
<form action="" method="post" class="survey-form">
<table>
<div id="topForm">
<div class="survey-form">
{{ form.event.errors }}
<label for="id_event">Event you participated in:</label>
{{ form.event }}
</div>
<div class="survey-form">
<label for="id_unit">Your unit:</label>
{{ form.unit }}
{{ form.unit.help_text }}
</div>
<div class="survey-form">
<label for="name">Your name:</label>
{{ form.name }}
{{ form.name.help_text }}
</div>
<div class="survey-form">
<label for="title">Title</label>
{{ form.title }}
{{ form.title.help_text }}
</div>
<div class="survey-form">
<label for="email">Your email address:</label>
{{ form.email }}
{{ form.email.help_text }}
</div>
</div>
<!-- Delete -->
{% if form.name.errors %}
<ol>
{% for error in form.name.errors %}
<li><strong>{{ error|escape }}</strong></li>
{% endfor %}
</ol>
{% endif %}
<!-- Delete Above -->
<!--Middle-->
<div id="middleForm">
<div class="survey-form">
{{ form.errors }}
<p class="question"></p>
<p class="bullets">{{ form.question_1 }}</p>
</div>
<div class="survey-form">
{{ form.question_2.errors }}
<p class="question"></p>
<p class="bullets">{{ form.question_2 }}</p>
</div>
<div class="survey-form">
{{ form.question_3.errors }}
<p class="question"></p>
<p class="bullets">{{ form.question_3 }}</p>
</div>
<div class="survey-form">
{{ form.question_4.errors }}
<p class="question"></p>
<p class="bullets">{{ form.question_4 }}</p>
</div>
<div class="survey-form">
{{ form.question_5.errors }}
<p class="question"></p>
<p class="bullets">{{ form.question_5 }}</p>
</div>
</div>
<!--Bottom -->
<div id="bottomForm">
<div class="survey-form">
{{ form.comment_6.errors }}
<label for="id_comment_6"></label>
{{ form.comment_6 }}
</div>
<div class="survey-form">
{{ form.comment_7.errors }}
<label for="id_comment_7"></label>
{{ form.comment_7 }}
</div>
<div class="survey-form">
{{ form.comment_8.errors }}
<label for="id_comment_8"></label>
{{ form.comment_8 }}
</div>
<div class="survey-form">
{{ form.comment_9.errors }}
<label for="id_comment_9"></label>
{{ form.comment_9 }}
</div>
<div class="survey-form">
{{ form.comment_10.errors }}
<label for="id_comment_10"></label>
{{ form.comment_10 }}
</div>
</div>
<tr>
<th colspan="2">
<div id="submit"><input type="submit" value="Submit" /></div>
</th>
</tr>
</table>
</form>
</div>


{% endblock content %}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment