Currently my submit button is only on one object which is because its outside the for loop, therefor it will only do the computation on the bottom file.
However if I put the button back inside the loop it will put a submit button for every row, but it wont be able to do the computation for multiple files, So I'm wondering how do I get one submit button for all the files, so it will do the computation for each file(which ever is currently checked)
(Searched this question before and none of the previously answered questions helped)
HTML File (Partially)
{% for f in files %}
<tr>
<td>{{ f.key }}</td>
<td>{{ f.last_modified | datetimeformat }}</td>
<td>{{ f.key | file_type }}</td>
<td>
<form class="download-form" action="{{ url_for('myview.action') }}" method="POST">
<input type="checkbox" name="key" value="{{ f.key }}">
{% endfor %}
<button type="submit" name="submit" value="submit">Submit</button>
</form>
</td>
</tr>
Python File(Partially)
@expose('/', methods=['POST', 'GET'])
@appbuilder.app.route('/', methods=['POST', 'GET'])
def action(self):
my_bucket = get_bucket()
s = my_bucket.objects.all()
t = getmyobject()
return render_template(
'page.html',
my_bucket=my_bucket,
base_template=appbuilder.base_template,
appbuilder=appbuilder,
page=s, t=t
)
you have jumbled up the form and for loops, try putting the for loop inside the form tag like this, and add button inside form and after closing of for loop.
<form class="download-form" action="{{ url_for('myview.action') }}" method="POST">
{% for f in files %}
<tr>
<td>{{ f.key }}</td>
<td>{{ f.last_modified | datetimeformat }}</td>
<td>{{ f.key | file_type }}</td>
<td><input type="checkbox" name="key" value="{{ f.key }}"></td>
</tr>
{% endfor %}
<button type="submit" name="submit" value="submit">Submit</button>
</form>
hope it helps.