#10781: Wrong way to style forms demonstrated in docs
---------------------------+------------------------------------------------
 Reporter:  boxed          |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Documentation  |     Version:  1.0       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 The docs has the following example:
 {{{
 <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 %}
                 {{ hidden }}
                 {% endfor %}
             {% endif %}

             {{ field.errors }}
             {{ field.label_tag }}: {{ field }}
         </div>
     {% endfor %}
     <p><input type="submit" value="Send message" /></p>
 </form>
 }}}
 This has the nasty side effect of not printing out the hidden variables if
 there are no non-hidden variables, in addition to making the code
 needlessly complex. This should be changed to:

 {{{
 <form action="/contact/" method="POST">
     {% for field in form.visible_fields %}
         <div class="fieldWrapper">
             {{ field.errors }}
             {{ field.label_tag }}: {{ field }}
         </div>
     {% endfor %}
     {# Include the hidden fields in the form #}
     {% for hidden in form.hidden_fields %}
         {{ hidden }}
     {% endfor %}

     <p><input type="submit" value="Send message" /></p>
 </form>
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10781>
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to