Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send multiple input field values with same name?

I have m2m field, lets say it have name 'relations', so i want to allow user to send as many relations as he wants. I add new input to html with javascript with same name, like so

<input type='text' name='relations' value='a' />
<input type='text' name='relations' value='b' />

in cleaned_data i receive only value of second input ('b'). How to receive both?

like image 938
user20955 Avatar asked Jan 25 '09 21:01

user20955


1 Answers

I don't know how to do that with Forms, but if you want to grab the values in the raw way, here's how I'd do:

relations = request.POST.getlist('relations')
like image 82
Tiago Avatar answered Oct 07 '22 12:10

Tiago