Opened 16 years ago

Closed 16 years ago

#10090 closed (duplicate)

small error in example code for looping over hidden form fields

Reported by: casey Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

<form action="/contact/" method="POST">

{% for field in form.visible_fields %}

<div class="fieldWrapper">

{# Include the hidden fields in the form #}
{% if forloop.first %}

{% for hidden in form.hidden_fields %}
{{ field }}
{% endfor %}

{% endif %}

{{ field.errors }}
{{ field.label_tag }}: {{ field }}

</div>

{% endfor %}
<p><input type="submit" value="Send message" /></p>

</form>

This is from "Looping Over Hidden and Visible Fields" at http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index. There is an error in the inner for loop foir hidden fields. In this loop, "{{field}}"" should be "{{hidden}}" to reflect the variable name in the inner loop.

Change History (1)

comment:1 by Alex Gaynor, 16 years ago

Resolution: duplicate
Status: newclosed

Closing as a dupe of #10009.

Note: See TracTickets for help on using tickets.
Back to Top