title: Using a dictionary to insert WTForm fields. jinja2.exceptions.UndefinedError: 'wtforms.fields.core.UnboundField object' has no attribute 'label'
body: <p>I am trying to populate a form in jinja2 using form fields that are in a dictionary.</p>
  
  <pre><code>#forms.py
  class MyForm(FlaskForm):
      name = StringField('New Name', validators=[DataRequired()])
  
      fields = {}
      fields['Field1'] = StringField('Field 1', validators=[DataRequired()])
      fields['Field2'] = StringField('Field 2', validators=[DataRequired()])
  
  #routes.py
  @app.route('/test', methods=['GET', 'POST'])
  def test():
      form = MyForm()
      return render_template('_test.html', form=form)
  </code></pre>
  
  <p>My python code is similar to the above code. If I try to insert the <code>name</code> field in jinja2 it works fine.</p>
  
  <pre><code>{{ form.name.label(class="form-control-label form-control-sm") }}
  </code></pre>
  
  <p>However, I don't know how to do the same for a field in the <code>fields</code> dictionary. If I use the following, it gives me an error.(<code>jinja2.exceptions.UndefinedError: 'wtforms.fields.core.UnboundField object' has no attribute 'label'</code>)</p>
  
  <pre><code>{{ form.fields['Field1'].label(class="form-control-label form-control-sm") }}
  </code></pre>
  
  <p>Is it possible to use a dictionary the way I tried to use it or is there an alternative if I have large amount of fields. My goal in using a dictionary was to use a jinja2 loop to iterate over the dictionary elements to insert all the fields without typing one by one.</p>