librelist archives

« back to archive

Dynamically update a validator's property for a wtforms HTML5 field?

Dynamically update a validator's property for a wtforms HTML5 field?

From:
Scott Werner
Date:
2014-05-04 @ 03:37
I have a wtforms_html5 field IntegerRangeField (input type range) which has
the validator NumberRange. The NumberRange's min/max values change and are
not constant. The rendered HTML5 range slider is constrained by the
validator's min and max values. Is there a better way to update the
NumbeRange validator's properties? My current solution can be found at:
https://gist.github.com/mercnet/5067d2c4fc6119ebbc92

For example, can I pass the min/max values when declaring the form,
e.g. form = AddRangeForm(obj=model, slider_max=value) which would update
the NumberRange validator? I would prefer that this logic be in the Form
class and not in my view.

-- 
Scott Werner