Difference between revisions of "Implementing HTML CheckBoxes in Jinja"

From PeformIQ Upgrade
Jump to navigation Jump to search
Line 22: Line 22:
</pre>
</pre>


=Gotchas=


* http://nesv.blogspot.com.au/2011/10/flask-gotcha-with-html-forms-checkboxes.html






[[Category:Jinja]]
[[Category:Jinja]]

Revision as of 11:00, 25 December 2014

Notes

Example

Template

{% for contact in contacts %}
    <input type="checkbox" id="id_{{contact.id}}" name="contacts" value="{{contact.id}}">
    <label for="id_{{contact.id}}">{{contact.name}}</label>
{% endfor %}

Flask

if request.method == "POST":
    selected_contacts = request.form.getlist("contacts")

Gotchas