jose
2006-May-24 17:35 UTC
[Rails] does select support arrays in a form with multiple models?
i have a one-to-many model (an addressbook of contacts with many phone numbers). i want to represent a select element so that its name is an array containing the phone_number id... <select id="phone_number_1_location_or_kind" name="phone_number[1][location_or_kind]"> <option value="Work">Work</option> <option value="Home">Home</option> <option value="Fax">Fax</option> </select> other form elements (such as text_field) allow for this, but i haven''t found a way of getting the select element to work with arrays. -- Posted via http://www.ruby-forum.com/.
Mark Reginald James
2006-Jun-14 13:48 UTC
[Rails] Re: does select support arrays in a form with multiple models?
jose wrote:> i have a one-to-many model (an addressbook of contacts with many phone > numbers). i want to represent a select element so that its name is an > array containing the phone_number id... > > <select id="phone_number_1_location_or_kind" > name="phone_number[1][location_or_kind]"> > <option value="Work">Work</option> > <option value="Home">Home</option> > <option value="Fax">Fax</option> > </select> > > other form elements (such as text_field) allow for this, but i haven''t > found a way of getting the select element to work with arrays.The above should work. Written as a helper call: select :phone_number, :location_or_kind, %w(Work Home Fax), {}, :index => 1 -- We develop, watch us RoR, in numbers too big to ignore.