On Nov 12, 5:18 am, Raji Mani <[EMAIL PROTECTED]>
wrote:
> Frederick Cheung wrote:
> > On Nov 11, 9:46 am, Raji Mani <[EMAIL PROTECTED]>
> > wrote:
> >> Hi,
>
> >> I have view page which takes all the information like contact's emails ,
> >> phones no's etc and saves different tables. I want to save more than one
> >> email id's for a particular contact.
>
> >> view page is something like this..
>
> > There's two separate problems here:
> > - how you manage the ui, ie adding extra textfields to the page
> > - how you convince rails to treat these textfields as an array.
>
> > The key to the second part is how you name the parameters. In
> > particular parameters ending with a [] are treated as arrays.
>
> > Fred
>
> Yes . I was able to submit more than one text field values.. but now my
> issue is how do i differentiate radio buttons with the same name.. both
> the radio buttons are getting selected :(.. here is the code
>
the builders yielded by form_for and fields_for have the same name, so
they'll be overwriting each other (which isn't what I thing you want).
Also shouldn't the second parameter to radio_button be index and not
'index' ?
Fred
> <% form_for :@contact do |f| %>
> <% @contact.emails.each_with_index do |email, index| %>
> <% fields_for "email[#{index}]", email do |f| %><tr> <td>
> Email  
> <%= f.select :email_type, %w(Business Personal),
> :include_blank => false %>
> <%= f.text_field :email %>
> <%= f.radio_button :isprimary ,'index' %>Primary
> </td></tr>
> <% end %>
> <% end %>
> <% end %>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---