DGT
DGT

Reputation: 2654

python form handle

How can I handle html form input (array) like the one below in Python:

<input type='hidden' name='a[]' value='some_value'>

The following doesn't work:

a_value = form["a"].value

Please help. Many thanks in advance.

Upvotes: 1

Views: 250

Answers (1)

dwich
dwich

Reputation: 1723

take a look at http://formencode.org/Validator.html#http-html-form-input

input name / value

names-1.fname   John
names-1.lname   Doe
names-2.fname   Jane
names-2.lname   Brown

will be parsed into

{'names': [
       {'fname': "John", 'lname': "Doe"},
       {'fname': "Jane", 'lname': 'Brown'},

UPDATE:

In your case <input type="hidden" name="item.a" value="5" /> will be parsed into item['a'] = 5

Upvotes: 4

Related Questions