I
I
Ingvar Von Bjork2019-12-06 15:41:40
Flask
Ingvar Von Bjork, 2019-12-06 15:41:40

How to get value from multiple fields with the same name?

I create a page with a form like this:

class SettingForm(Form):
    index = TextField('index')
    login = TextField('login')
    password = TextField('password')
    fullName = TextField('fullName')
    organization = TextField('organization')
    department = TextField('department')

form = SettingForm()

return render_template('page.html', form = form)

In html, I reuse some of the form fields. Actually how to get the value from these fields as an array?
In php, as far as I remember, the fields could look something like this . How to do this in Flask? <input type="text" name="login[]">

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ingvar Von Björk, 2019-12-09
@DeboshiR

request.form.getlist('login')

S
Sergey Gornostaev, 2019-12-06
@sergey-gornostaev

request.args.getlist('param_name')will return a list if multiple parameters with the same name are passed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question