I have a page with multiple links to redirect the user to different pages. I thought using a form would be nicer, so I defined a WTForms Form
with multiple SubmitFields
. How do I determine which button was clicked and redirect based on that?
class MainForm(Form):
user_stats = SubmitField('User Stats')
room_stats = SubmitField('Room Stats')
@main.route('/')
@login_required
def index():
form = MainForm()
return render_template('index.html', form=form)
<form action="#" method="post">
{{ wtf.quick_form(form) }}
</form>
You added two buttons to the form, so check which of the fields' data is
True
.