Displaying 2 results from an estimated 2 matches for "phone_type_id".
2006 Jun 12
3
Multiple Form Fields with Same Model?
...39;'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 => "ph...
2007 May 09
0
How can I specify the selected value in collection_select when fieldname different than variable?
...e_types
[code]
#
#Create a Phone type select List
#Take a list of html options
#
def get_phone_types(fieldname)
@phones = PhoneType.find(:all, :order => "description ASC");
#TODO, how to assign the value from phone.phone_type.id?
collection_select(fieldname, "phone_type_id",
@phones, :id, :description);
end
[/code]
Also, is it possible for me to call the PhoneType.find and save the
resulting array "@phones" for the life of the request across multiple
method calls? I''m assuming I just need to make @phones an instance
variable, but I'...