title: Dynamic forms with Flask?
body: <pre class="lang-html prettyprint-override"><code>    &lt;link rel=&quot;stylesheet&quot; href=&quot;/static/css/addtopic.css&quot;&gt;
      &lt;div class=&quot;main&quot;&gt;
              {% if acctype == &quot;teacher&quot; %}
                  &lt;form method=&quot;POST&quot; action=&quot;&quot;&gt;
                      {{ form.hidden_tag() }}
                      &lt;div class=&quot;form-group&quot;&gt;
                          {{ form.topicname }}
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                          {{ form.contents }}
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                          {{ form.contents }}
                      &lt;/div&gt; 
                  &lt;/form&gt;
              {% else %}
              {% endif %}
      &lt;/div&gt;
  </code></pre>
  <p>I tried to make dynamic forms where the contents part can have multiple input boxes but I dont know how to actually use it
  heres the forms</p>
  <pre class="lang-py prettyprint-override"><code>class ContentForm(FlaskForm):
      section = StringField(validators=[DataRequired()])
  
  class ExerciseForm(FlaskForm):
      exercise = StringField(validators=[DataRequired()])
      testcase = StringField(validators=[DataRequired()])
  
  class AddTopicForm(FlaskForm):
      topicname = StringField('Topic Name', validators=[DataRequired(), Length(min=2, max=100)])
      contents = FieldList(FormField(ContentForm), min_entries=1)
      exercises = FieldList(FormField(ExerciseForm), min_entries=0)
  </code></pre>
  <p>Can anyone tell me how to make it dynamic in that I click a button and one more input field pops up, and when I submit I get all the data?</p>