Catherine .. wrote:
Donnie Jones wrote:
Hello,
I'm trying to create a form that will allow a user to submit a list of phone numbers, but the list is dynamically created. Thus allowing my form to submit an unknown number of phone numbers.
Here is some of the code I have been trying:
<%= collection_select( "phone", "phone_type_id", PhoneType.find(:all, :order => "position"), :id, :description ) %>
( <%= text_field "phone", "area_code", :class => "phones" %> ) <%= text_field "phone", "prefix", :class => "phones" %> - <%= text_field "phone", "suffix", :class => "phones" %> ext. <%= text_field "phone", "extension", :class => "phones" %>
<%= link_to_remote("add", :update => "phones-list", :url => { :action => "add_phone" }, :loading => "", :complete => "" ) %>
The link_to_remote would use AJAX to insert the fields to add a new phone number, but the issue is that I don't know how to incorporate an id or count field into the fields so controller can tell the diffrence between the fields in the params. I tried using the phones with '' based upon the agile book, first edition, pg 356 and the rails docs at Peak Obsession
Any help would be greatly appreciated. Thanks. __ Donnie
The only way I could think about how to do something like this would be to have a table relating users to a phone number, that way they could have as many phone numbers as they wanted. Then as they added a number if would get entered into the list, your method would go out and get the numbers (including the one you just added) and then render a partial inside of a div. Not sure if this helps,
-S