in flask-WTF forms how to custom the size of text field?
·
Answer a question
In forms created by flask-wtf, how can I specify the height and width of text field input
{% extends "base.html" %}
{% block title %} Title {% endblock %}
{% block body %}
<form method="POST">
{{ form.textfld.label }} <br>
{{form.textfld(size=100)}}
</form>
{% endblock %}
This is the only example I can find which changes only the width but not height. I tried to add a class to it and target the class in base.html but nothing is changed.
Answers
if you add a render_kw
dict to the form specification:
class Form(Form):
field = SomeField(*args, render_kw=dict(class='my_class'))
then in the HTML the text class="my_class"
will be automatically rendered for the field, so you customise the properties via the CSS class.
更多推荐
所有评论(0)