title: Filling WTForms FormField FieldList with data results in HTML in fields
body: <p>I have a Flask app in which I can populate form data by uploading a CSV file which is then read. I want to populate a FieldList with the data read from the CSV. However, when I try to populate the data, it enters raw HTML into the TextFields instead of just the value that I want. What am I doing wrong?</p>
  
  <p><strong>app.py</strong></p>
  
  <pre><code>from flask import Flask, render_template, request, url_for
  from flask.ext.wtf import Form
  from wtforms import StringField, FieldList, FormField, SelectField
  from wtforms.validators import DataRequired
  from werkzeug.datastructures import MultiDict
  
  app = Flask(__name__)
  app.config['SECRET_KEY']='asdfjlkghdsf'
  
  # normally student data is read in from a file uploaded, but for this demo we use dummy data
  student_info=[("123","Bob Jones"),("234","Peter Johnson"),("345","Carly Everett"),
                ("456","Josephine Edgewood"),("567","Pat White"),("678","Jesse Black")]
  
  class FileUploadForm(Form):
      pass
  
  class StudentForm(Form):
      student_id = StringField('Student ID', validators = [DataRequired()])
      student_name = StringField('Student Name', validators = [DataRequired()])
  
  class AddClassForm(Form):
      name = StringField('classname', validators=[DataRequired()])
      day = SelectField('classday', 
                        choices=[(1,"Monday"),(2,"Tuesday"),(3,"Wednesday"),(4,"Thursday"),(5,"Friday")],
                        coerce=int)
  
      students = FieldList(FormField(StudentForm), min_entries = 5) # show at least 5 blank fields by default
  
  @app.route('/', methods=['GET', 'POST'])
  def addclass():
      fileform = FileUploadForm()
      classform = AddClassForm()
  
      # Check which 'submit' button was called to validate the correct form
      if 'addclass' in request.form and classform.validate_on_submit():
          # Add class to DB - not relevant for this example.
          return redirect(url_for('addclass'))
  
      if 'upload' in request.form and fileform.validate_on_submit():
          # get the data file from the post - not relevant for this example.
          # overwrite the classform by populating it with values read from file
          classform = PopulateFormFromFile()
          return render_template('addclass.html', classform=classform)
  
      return render_template('addclass.html', fileform=fileform, classform=classform)
  
  def PopulateFormFromFile():
      classform = AddClassForm()
  
      # normally we would read the file passed in as an argument and pull data out, 
      # but let's just use the dummy data from the top of this file, and some hardcoded values
      classform.name.data = "Super Awesome Class"
      classform.day.data = 4 # Thursday
  
      # pop off any blank fields already in student info
      while len(classform.students) &gt; 0:
          classform.students.pop_entry()
  
      for student_id, name in student_info:
          # either of these ways have the same end result.
          #
          # studentform = StudentForm()
          # studentform.student_id.data = student_id
          # studentform.student_name.data = name
          #
          # OR
          student_data = MultiDict([('student_id',student_id), ('student_name',name)])
          studentform = StudentForm(student_data)
  
          classform.students.append_entry(studentform)
  
      return classform
  
  
  if __name__ == '__main__':
      app.run(debug=True, port=5001)
  </code></pre>
  
  <p><strong>templates/addclass.html</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Flask FieldList Demo&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Add Class&lt;/h1&gt;
          {% if fileform %}
          &lt;div&gt;
              &lt;p&gt;Add class from file:&lt;/p&gt;
              &lt;form action="" method="post" enctype="multipart/form-data" name="fileform"&gt;
                  {{ fileform.hidden_tag() }}
                  &lt;p&gt;&lt;input type="submit" name="upload" value="Upload"&gt;&lt;/p&gt;
              &lt;/form&gt;
          &lt;/div&gt;
          &lt;hr&gt;
          {% endif %}
          &lt;div&gt;
              &lt;form action="" method="post" name="classform"&gt;
                  {{ classform.hidden_tag() }}
                  Class Name: {{ classform.name }}&lt;br&gt;
                  Day: {{ classform.day }}&lt;br&gt;
                  &lt;br&gt;
                  &lt;div&gt;
                      &lt;table&gt;
                          &lt;tr&gt;
                              &lt;th&gt; Student Number &lt;/th&gt;
                              &lt;th&gt; Name &lt;/th&gt;
                          &lt;/tr&gt;
                          {% for student in classform.students %}
                          &lt;tr&gt;
                              &lt;td&gt;{{ student.student_id }}&lt;/td&gt;
                              &lt;td&gt;{{ student.student_name }}&lt;/td&gt;
                          &lt;/tr&gt;
                          {% endfor %}
                      &lt;/table&gt;
                  &lt;/div&gt;
                  &lt;p&gt;&lt;input type="submit" name="addclass" value="Add Class"&gt;&lt;/p&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The offending code snippet happens at the line <code>classform.students.append_entry(studentform)</code>. 
  I can post the output HTML if required. What I expect is something like this:
  <img src="https://i.stack.imgur.com/RKbjMm.png" alt="Expected Output">
  What I get instead is:
  <img src="https://i.stack.imgur.com/Vs5nlm.png" alt="enter image description here"></p>