I have 3 text fields in a form , all with the same method, since those params will be inserted via a loop which is set up in the create action. However, I''m noticing that the form is only sending through the 1st value and leaving out the additional 2. In my form I have this: <%= text_field(:cantitle, :title_opt)%> <%= text_field(:cantitle, :title_opt)%> <%= text_field(:cantitle, :title_opt)%> Even though I put input into each , the params came through as such: {"cantitle"=>{"title_opt"=>"CEO"}, # so the 2nd and 3rd were skipped. In the controller I have this loop- # which if 3 values were submitted , 3 records would be created. a = (params[:cantitle][:title_opt]) a.each {|x| cantitle = Cantitle.new cantitle.title_opt = x cantitle.save } Any ideas how to get each value through ? Also, I''m wondering what would happen if someone filled in the 1st and 3rd box and left the 2nd blank. Do I have to account for a null value ? Stuart -- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It is not possible to have same name for all the fields, that''s why only one field is getting populated.> Any ideas how to get each value through ? Also, I''m wondering what would > happen if someone filled in the 1st and 3rd box and left the 2nd blank. Do > I have to account for a null value ? > > Stuart >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bala, thanks - you always come through for me. Actually though it is possible (as I just learned) by adding "index" = x So now I have the text fields as such: <%= text_field(:cantitle, :title_opt, "index" => 1)%> <%= text_field(:cantitle, :title_opt, "index" => 2)%> <%= text_field(:cantitle, :title_opt, "index" => 3)%> Which get translated into : <input id="canlocation_1_city" name="canlocation[1][city]" size="30" type="text" /> <input id="canlocation_2_city" name="canlocation[2][city]" size="30" type="text" /> <input id="canlocation_3_city" name="canlocation[3][city]" size="30" type="text" /> And params are such: "cantitle"=>{"1"=>{"title_opt"=>"CEO"}, "2"=>{"title_opt"=>"COO"}, "3"=>{"title_opt"=>"CIO"}}, Stuart On 10/25/06, Bala Paranj <bcparanj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > It is not possible to have same name for all the fields, that''s why only > one field is getting populated. > > > > Any ideas how to get each value through ? Also, I''m wondering what would > > happen if someone filled in the 1st and 3rd box and left the 2nd blank. Do > > I have to account for a null value ? > > > > Stuart > > > > > >-- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Great, looks like we can learn a lot from the Rails API.> "cantitle"=>{"1"=>{"title_opt"=>"CEO"}, "2"=>{"title_opt"=>"COO"}, > "3"=>{"title_opt"=>"CIO"}}, > > Stuart >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---