user2990084
user2990084

Reputation: 2840

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.

Upvotes: 4

Views: 9267

Answers (1)

Bartosz Marcinkowski
Bartosz Marcinkowski

Reputation: 6861

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() }}

Upvotes: 12

Related Questions