[Flask] Show Value after error Flask/Wtforms

Ben Duncan linux4ms at gmail.com
Wed Sep 18 09:02:10 EDT 2019


In Flask / Wtforms, if you fail the validation, how to
show the values back on the web form ?
Sample:

 <div>{{ form.email.label.text }}</div>
         <input
               style='width: 350px;'
               name='email'
               id='email'
               type='text'
               size='30'
          >
        {% if form.email.errors %}
         <ul class="errors">
          {% for error in form.email.errors %}
            <li>{{ error }}</li>
        {% endfor %}
        </ul>
        {% endif %}

with the class being defined:
class ContactForm(FlaskForm):
      name = StringField("Name: ", validators=[DataRequired()])
      email = StringField("Email: ", validators=[Email()])

If there was an error of any sort, I would like the form errors to be
re-displayed...

Thanks

*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20190918/a8d1372b/attachment.html>


More information about the Flask mailing list