Questions tagged [wtforms]

WTForms is a versatile tool for validating and displaying forms in Python applications.

The email validation feature in Flask WTForm for Python does not accept dashes as valid characters

I need help validating an email input field in Flask for a user. Currently, I am using WTForms' Email validation method, but it does not allow users to include dashes in their email addresses. Here is my code: from flask_wtf import FlaskForm from wtforms i ...

Issue with WTForms form submission: validation errors not displayed despite form not being properly submitted

I'm having issues trying to implement file uploads using flask-uploads. I've encountered some obstacles while working on it and I need some assistance. Below, I will display my flask view function along with the HTML code, in hopes that someone can help me ...

Tips for customizing WTForm fields with unique CSS classes

I've recently put together a basic form snippet: class PostForm(FlaskForm): # for publishing a new blog post title = StringField("Title", validators=[DataRequired()]) submit = SubmitField('Post') The structure of my HT ...

Flask does not accept user input directly from WTForms

I am currently working on developing an application using Flask with WTForms. Here is the setup in my controller.py file: @mod_private.route('/portfolio/', methods=['GET', 'POST']) @login_required def portfolio(): print "in portfolio" # This line is ...

Assign a CSS class to a specific option within a SelectField in a WTForms form

Could someone explain the process of assigning a CSS class to the choices values? I am looking to customize the background of each choice with a small image. How can this be done using wtforms and CSS? class RegisterForm(Form): username = TextField( ...

Display or conceal numerous WTForm labels

Is there a more efficient way to hide/show multiple wtform labels? Currently, I am achieving this with the following code: HTML: {{ render_field(var_1, class = "class_1") }} {{ render_field(var_2, class = "class_1") }} {{ render_field(var_3, class = " ...