I am trying generate a checklist in a html table from a json file using BooleanField() So far I have it without using wtforms:
from view.py
from app import app
from flask import render_template
json_data = [{'Description':'Red', 'id':'f1'},{'Description':'Green', 'id':'f2'},{'Description':'Blue', 'id':'f3'}]
@app.route('/taggs', methods = ['GET', 'POST'])
def taggs()
return render_template('taggs.html', jdata = json_data)
from taggs.html
<form role="form" method= "post">
<table id='ctable'>
<thead>
<tr>
<th data-field="Description"></th>
<th data-field="Selection"></th>
</tr>
</thead>
<tbody>
</tbody>
{% for i in jdata %}
<tr>
<td>{{ i.Description }}</td>
<td><input type ="checkbox" id = "{{ i.id }}"></td>
</tr>
{% end for%}
</table>
</form>
Is there a way of generating form fields using a list in wtforms? or do I have to create a class and declare each variable in the list?