N
N
nano_e_t_42016-08-01 17:51:42
Flask
nano_e_t_4, 2016-08-01 17:51:42

How to set the name of the form in the template?

Hello everyone
There is a form in the template:

<form action="/name.html" method="POST" enctype="multipart/form-data">
        {{form.hidden_tag()}}
       <p>Введите ваше Имя:</p>
       {{form.name(class="send-form")}}
        {% for error in form.errors.name %}
        <span style="color:red;" class="flash-error">{{error}}</span>
        {% endfor %}

in the browser with name="name". but you need to set a different name,
I try to do it like this:
{{form.name(class="send-form", name="bla")}}
the template is rendered with an error:
html_params() got multiple values for keyword argument 'name'

at the same time, the id is manually set without problems
to create forms using flask wtforms

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
VanSanblch, 2016-08-01
@VanSanblch

Are you using Flask-WTF? If so, is it not possible to specify the name for the field when creating the form?
I assume you now have something like this:

class MyForm(Form):
    name = StringField()

Well, change it to
new_name = StringField()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question