Changes between Initial Version and Version 1 of Ticket #25481


Ignore:
Timestamp:
Sep 28, 2015, 12:48:16 PM (9 years ago)
Author:
Tim Graham
Comment:

It seems there are many other examples on that page that could also be updated similarly. Did you single this one out for any reason? I don't know that it's really necessary, but I don't have a great argument against it besides it will be a bit repetitive in all the examples, especially if the implementation is something like {% if field.help_text %}<p>{{ field.help_text }}</p>{% endif %} so we don't output empty paragraph elements.

I removed the "In addition, but unrelated" issue from the description as I don't think there's a need to complicate the example with a particular HTML structure. ("{{ field.errors }} might need a span for the example to be usable in real life.") {{ field.errors }} already includes a <ul> which can be styled, correct?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25481

    • Property Triage Stage UnreviewedAccepted
    • Property Type UncategorizedCleanup/optimization
  • Ticket #25481 – Description

    initial v1  
    11On https://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields
    22
    3 the example of looping over the form's fields omits {{ field.help_text }}, though this field is outputted by default by {{ form.as_ul }}. I believe we should add {{ field.help_text }} in the example to be both consistent and complete.
    4 
    5 In addition, but not related, {{ field.errors }} might need a span for the example to be usable in real life.
     3The example of looping over the form's fields omits `{{ field.help_text }}`, though this field is outputted by default by `{{ form.as_ul }}`. I believe we should add `{{ field.help_text }}` in the example to be both consistent and complete.
    64
    75From the docs:
    86---
    9 Looping over the form’s fields
     7Looping over the form’s fields
    108
    119If you’re using the same HTML for each of your form fields, you can reduce duplicate code by looping through each field in turn using a {% for %} loop:
    12 
    1310
    1411{{{
     
    1916    </div>
    2017{% endfor %}
    21 
    22 {% for field in form %}
    23     <div class="fieldWrapper">
    24         {{ field.errors }}
    25         {{ field.label_tag }} {{ field }}
    26     </div>
    27 {% endfor %}
    2818}}}
Back to Top