Reputation: 45
I have a form built with python + webapp2 + jinja2. All the values submitted appear to be strings. One of the fields is a multiple select and only the first selected item gets submitted. Is there a way to have that field submitted as an array of all the selected values.
I have for the html template
<select name="some_list" multiple>
<option value="red">Red</option>
<option value="red">Blue</option>
<option value="red">Yellow</option>
</select>
In the python class
some_list = []
some_list = self.request.get('some_list')
Upvotes: 3
Views: 1884
Reputation: 57168
The request object contains a MultiDict which means you can use another method to get all values passed for a given key. Try something like:
self.request.params.getall('some_list')
Upvotes: 6