My form in Flask WTF has two fields: name and email. When I submit the form successfully, the name field gets reset while the email field retains its values. The behavior is the same across browsers (I've tried it on Chrome and Firefox) so far. Here are screen shots for what I mean:
Here are the relevant code snippets:
class NameForm(Form):
name = StringField('What is your name?', validators=[Required()])
email = StringField('What is your email?', validators=[Required(), Email()])
submit = SubmitField('Submit')
@app.route('/', methods=['GET', 'POST'])
def index():
form = NameForm()
if form.validate_on_submit():
name = form.name.data
return render_template('index.html', form=form, name=name)
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Flasky{% endblock %}
{% block page_content %}
<div class="page-header">
<h1>Hello, {% if name %}{{ name }}{% else %}Stranger{% endif %}!</h1>
</div>
{{ wtf.quick_form(form) }}
{% endblock %}
Any idea what's causing this behavior?