I saw that while using WTF_Forms we can render a form in basic way as: render form in basic way
<form method="POST" action="{{ url_for('login') }}">
{{ form.csrf_token }}
{{ form.email.label }} {{ form.email(size=30) }}
{{ form.password.label }} {{ form.password(size=30) }}
<input type="submit" value="Log In">
</form>
I also saw that by using bootstrap-flask, we can render a form quickly as: shown here
{% extends "base.html" %}
{% from 'bootstrap5/form.html' import render_form %}
{% block title %}Login{% endblock %}
{% block content %}
<div class="container">
<h1>Login</h1>
{{ render_form(form) }}
</div>
{% endblock %}
But when using render_form(form), I cannot control size of the input to display (example in earlier code: size=30
Is there any way to control size with render_form() ?
I expect to control size while using render_form(form)
To add some constraints to your form and then render your form by using bootstrap macro (render_form) you have to create a class of your form inside your python file.
WTForms quick start
But still the question is:
in other words...
Now the validators comes in handy.
WTForms - Validators
Validators is an object which contains many helpfull methods that will make your life easier. From setting a length of characters inside your input to checking if the value is proper e-mail adress or a weblink etc...
Let's use previous class and add that functionality:
So simple pseudo code is: