I'm trying to integrate Flask as the backend for the UI I'm working with.
Unfortunately the UI already has the CSS and JavaScript set up for the forms (to accommodate for the UI but also for older versions of IE and other cases).
The first problem that I'm running into is that there is already a label for the fields. If I use the .labels attribute in the template:
{{ form.username.label }} then it creates an extra label which I can't seem to add any attributes to for the CSS/JavaScript. However if I leave the .label attribute off then it creates an extra blank text field above the username input.
The code in my forms.py file is:
class LoginForm(FlaskForm): username = StringField('Username', validators=[DataRequired()]) Am I missing something on this?
The second part is adding attributes to the form itself. I've found how to add the HTML class attribute using class_='classname', but the Flask-WTF and WTForms documentation don't seem to touch on any other attributes (such as autcomplete="off" or placholder="username")
Is there some way to accomplish this with Flask-WTF or WTForms that I'm just missing? Am I limited to manual attributes and/or Jinja macros for this type of functionality? I can't imagine this is something that would be missing form WTForms and Flask-WTF but I also don't see it mentioned anywhere in the docs or on Google/StackOverflow.
Thanks!