title: Add a css class to a field in wtform
body: <p>I'm generating a dynamic form using wtforms (and flask). I'd like to add some custom css classes to the fields I'm generating, but so far I've been unable to do so. Using the answer I found <a href="https://stackoverflow.com/questions/11309779/wtforms-add-a-class-to-a-form-dynamically">here</a>, I've attempted to use a custom widget to add this functionality. It is implemented in almost the exact same way as the answer on that question:</p>
  
  <pre><code>class ClassedWidgetMixin(object):
    """Adds the field's name as a class.
  
    (when subclassed with any WTForms Field type).
    """
  
    def __init__(self, *args, **kwargs):
      print 'got to classed widget'
      super(ClassedWidgetMixin, self).__init__(*args, **kwargs)
  
    def __call__(self, field, **kwargs):
      print 'got to call'
      c = kwargs.pop('class', '') or kwargs.pop('class_', '')
      # kwargs['class'] = u'%s %s' % (field.name, c)
      kwargs['class'] = u'%s %s' % ('testclass', c)
      return super(ClassedWidgetMixin, self).__call__(field, **kwargs)
  
  
  class ClassedTextField(TextField, ClassedWidgetMixin):
    print 'got to classed text field'
  </code></pre>
  
  <p>In the View, I do this to create the field (ClassedTextField is imported from forms, and f is an instance of the base form):</p>
  
  <pre><code>  f.test_field = forms.ClassedTextField('Test Name')
  </code></pre>
  
  <p>The rest of the form is created correctly, but this jinja:</p>
  
  <pre><code>{{f.test_field}}
  </code></pre>
  
  <p>produces this output (no class):</p>
  
  <pre><code>&lt;input id="test_field" name="test_field" type="text" value=""&gt;
  </code></pre>
  
  <p>Any tips would be great, thanks.</p>