I am using python 3 and flask in a webproject. I have multiple forms on a single page. Forms have a hidden_tag()
, which is the csrf_token
.
The problem is that the id's of all csrf_token
are the same.
[DOM] Found 2 elements with non-unique id #csrf_token:
I could use ajax or simply use a new page for the form, but I'd like to understand whether there is a fix for that.
I tried to assign a custom id to each hidden_tag()
:
{{ form.hidden_tag(id="tag_1") }}
But it tells me:
TypeError: hidden_tag() got an unexpected keyword argument 'id'
So far I was not able to find a solution.
EDIT:
The error is displayed by the browser in the console:
EDIT:
I am trying to add the hidden_tag
, so it will overwrite the original hidden tag, but I cant figure out how the value is created.
hidden_tag = HiddenField('EditUserPasswordHiddenTag', default="the value")
That is what I got:
<input id="hidden_tag" name="hidden_tag" type="hidden" value="the value">