title: Submit WTform with dynamically generated fields
body: <p>I have a form where users can dynamically add fields to it. While submitting this form, backend only sees the fields which backend generated</p>
  
  <pre><code>#forms.py
  
  class ExpensesForm(FlaskForm):
      expense_name = StringField('Expense_Item', validators=[DataRequired()])
      cost = FloatField('Cost', validators=[DataRequired()])
      due_date = DateField('Due Date', format='%Y-%m-%d', validators=[DataRequired()], default=datetime.datetime.today().date())
      type = SelectField('Role', choices=[('mutual', 'Mutual'),
                                          ('personal#1', 'Personal #1'),
                                          ('personal#2', 'Personal #2')
                                          ])
  </code></pre>
  
  <p>I'm passing this form with 
  <code>return render_template('index.html', form=form, ...)</code> from the <code>main.py</code> to <code>index.html</code></p>
  
  <p>All 4 fields are generated via;</p>
  
  <pre><code>&lt;form class="form-horizontal" id="main-form" enctype=multipart/form-data role="form" method="post" action="/"&gt;
          &lt;input type="hidden" name="count" value="1"/&gt;
          {{ form.csrf_token }}
  
          {{ form.expense_name(placeholder="Expense Name", id="expense_1", value="") }}
          {{ form.cost(placeholder="Cost", id="cost_1", class="cost", value="") }}
          {{ form.due_date(id="due_date_1") }}
          {{ form.type(placeholder="Type", id="type_1") }}
          &lt;button id="b1" class="btn btn-info add-more" type="button"&gt;+&lt;/button&gt;
          &lt;small&gt;Press + to add another set of fields.&lt;/small&gt;
          &lt;br&gt;
          &lt;hr&gt;
          &lt;button class="btn btn-sm btn-success" type="submit"&gt;Post Expense&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>A JQuery snippet generates the same fields with different(unique) id's after each button press as a row of new fields after the last <code>#type_</code> id. </p>
  
  <p>When I hit the submit button, the backend only receives the first row not the generated ones. </p>
  
  <p>What am I missing here?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code># main.py
  @main_blueprint.route('/', methods=['GET', 'POST'])
  def index():
      dates = []
      form = ExpensesForm(request.form)
      if request.method == 'POST':
          print(form.data)
          # prints the following even when the browser sends more than 1 set of data:
          # {'due_date': None, 'csrf_token': long_hash, 'expense_name': 'Electric', 'cost': 13.0, 'type': 'mutual'}
          if form.validate_on_submit():
              for n in range(len(form.expense_name.data)):
                  if form.expense_name.raw_data[n] != '':
                      data = Expenses(form.expense_name.raw_data[n].title(),
                                      form.cost.raw_data[n],
                                      datetime.datetime.strptime(form.due_date.raw_data[n], '%Y-%m-%d').date(),
                                      form.type.raw_data[n].title(),
                                      )
                      print(data)
                      db.session.add(data)
                      db.session.commit()
          return redirect(url_for('main.index'))
      expenses = db.session.query(Expenses).all()
      # expenses_schema = ExpensesSchema()
      # output = expenses_schema.dump(expenses).data
  
      output = []
      for i in expenses:
          output.append(i.__dict__)
      return render_template('index.html', form=form, expenses=output)
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Since <code>form.data</code> is a dict I can't have the names matching with the new fields. But even if I give unique names to the added fields the backend only displays the initial form fields with <code>print(form.data)</code> but if I do;</p>
  
  <pre><code>    for k, v in request.form.items():
          print(k, v)
  </code></pre>
  
  <p>I get all the fields. Doesn't seem the right way to me. Any thoughts?</p>