comicgeekspeak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-14 18:53 UTC
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? Or How can I specify the name of an ajax auto completer? Thanks, Bry --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
comicgeekspeak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-14 19:12 UTC
Re: Two form fields, same name. How to get the data?
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? Thanks, Bry --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think you can use params[:tag][:1]. place debug(params) in your view to see how the feilds are being passed. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/14/06, comicgeekspeak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <comicgeekspeak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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.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. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
comicgeekspeak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-15 13:10 UTC
Re: Two form fields, same name. How to get the data?
I figured out the solution. I needed to do this: params[:tag][''1''][''tag''] However, since I added the indexes to my auto_completes the ajax auto complete no longer works. So now I''m stumped again. Bry --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---