Two form fields, same name. How to get the data?

Hi there,

I have a form with two fields that have the same name. I didn't generate the names, Rails did. I'm using two ajax auto completers.

On other webservers, if I had two fields with like names, I would get a comma delimited string of the two values. Rails however is only returning the first value.

How can I retrieve both values?


How can I specify the name of an ajax auto completer?



Ok, I figured out that I need to put :index => 1 and :index => 2 on my fields.

Now I need to know how to read the values in my controller? I can't just do a simple params[:fieldname]

These are my two form fields:

name="tag[1][tag]" name="tag[2][tag]"

how do I retrieve the values?



I think you can use params[:tag][:1].

place debug(params) in your view to see how the feilds are being passed.

Might want to add a debug statement to the view to see what is in params, I don't know how rails handles this. FYI browsers send the values null separated, then it's up to the cgi library how to deal with them.


I figured out the solution. I needed to do this:


However, since I added the indexes to my auto_completes the ajax auto complete no longer works. So now I'm stumped again.