I'm not quite sure how this question fits. I hope I get there.
For example, I have a table full of addresses on the page. Their number is dynamic (it can be 5 or 10 or any other quantity). And I want the ability to edit them on one page.
My approach was to create a form with wtforms to edit a single address and multiply this in jinja2 for loop and add to the html name and id loop.index0 from itereation, so I can extract each row of data manually and return it to my form when I I want to evaluate it.
So the form for this example would look like this:
class AdressForm(Form): name = TextField()
So, now my aproach template looks like this (split into one input field):
{% for address in addresses %} {{ forms.render_field(addressform.name, id = "name_" ~ loop.index0, name = "name_" ~ loop.index0, value = address.name) }} {% endfor %}
(forms.render_field is just a macro to indicate the correct classes for the wtforms field function, as they are used in many tutorials)
So this does not work, since you cannot pass the name parameter manually for the field function, since wtforms create the name html parameter from variblameame from the inline form.
So, there is a way to add a prefix or postfix to the name of the form I want to display. Or is this an XY problem, and my approach is not true.
or I do it all on my own (I really try to avoid this)