Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output type="number" with flask-wtforms

from flask.ext.wtf.html5 import NumberInput

class Form(Form):
    value = NumberInput( [Required()])
    submit = SubmitField('Next')

{{ form.value }}

The code above will output this:

<wtforms.widgets.html5.NumberInput object at 0x3c94a50>

Well, what i am expecting is:

<input type="number">

Basically, the question is how can I render an input type="number" with wtforms.

like image 434
user2990084 Avatar asked Dec 20 '22 06:12

user2990084


1 Answers

First of all, your value should be a field, not a widget.

value = IntegerField(widget=NumberInput())

WTForms fields generate html on call, so try

{{ form.value() }}
like image 154
Bartosz Marcinkowski Avatar answered Dec 22 '22 00:12

Bartosz Marcinkowski