I\'m building a website with the Python Flask framework in which I use WTForms. In one form I\'ve got a RadioField defined as follows:
display = RadioField(\
You need to run myForm.process()
after adding the choices and setting the default
property:
myForm = MyForm()
myForm.display.choices = [('ONE', 'one'), ('TWO', 'two')]
myForm.display.default = 'ONE'
myForm.process() # process choices & default
This is because the default
is propagated to the field value (and, in the case of RadioField
, the checked
property) in the process
method, which is called in the constructor.