I'm trying to set the default value for a select field that is dynamically generated using a for loop using jinja within the html page and i cant find a solution to do this in the documentation. Basically i need a way to set the default value of the selectfield using jinja if possible.
I cant set the default value from the routes side or the forms side in python because the fields are made dynamically and the default values need to be different depending on the choices. I can set the default value if i use a stringfield but not a selectfield.
Can anyone help me find a solution for this problem? Could i switch to a different formfield to use instead of selectfield?
2nd question would be can i build and use a manual html field that would still work with the other wtform fields when i submit if i set the id and name to be what it would be when the html page is generated? I might have a way to solve my problem that way if its possible.
code for how it would be done with stringfield that i want translated to selectfield:
{% for d in data %}
{{ form.type.label(class="label") }}
{{ form.type(class="field", value=d.type) }}
{% endfor %}
Thank you