Add a css class to a field in wtform

You actually don’t need to go to the widget level to attach an HTML class attribute to the rendering of the field. You can simply specify it using the class_ parameter in the jinja template. e.g. {{ form.email(class_=”form-control”) }} will result in the following HTML:: <input class=”form-control” id=”email” name=”email” type=”text” value=””> to do this dynamically, … Read more

WTForms Can I add a placeholder attribute when I init a field?

Updated for WTForms 2.1 You can now as of WTForms 2.1 (December 2015) set rendering keywords by using the render_kw= parameter to the field constructor. So the field would look like: abc = StringField(‘abc’, [InputRequired()], render_kw={“placeholder”: “test”}) Note while this is possible; it does start to bridge the line between code and presentation; so use … Read more