i have many fields in my form i was trying to apply different css to neighbour forms fields like
<li class='thiscolor' >
<field>
</li>
<li class='thatcolor' >
<field>
</li>
if there a way like
{% for field in form %}
**{% if forloop.counter%2 == 0 %}**
<li class='thiscolor'>
{% else%}
<li class='thatcolor'>
{%endif}
{{field}}
</li>
{% endfor %}
for forloop.counter ?
Thanks a lot!
The cycle tag is designed for this type of problem:
{% for field in form %}
<li class="{% cycle 'thiscolor' 'thatcolor' %}">{{ field }}</li>
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With