Mark Reginald James
2005-Oct-26 14:46 UTC
Re: collection_select question about selected_value
Paul Welty wrote:> collection_select(:client, :company_id, @companies, :id, :name, { > :selected_value => 2 , :prompt => "Please select a company..." }) > > Returns a functioning SELECT element, but it won¹t select the second item. > (BTW, using the selected_value as a string doesn¹t work either) > > Am I doing something wrong, or is this impossible? > > If impossible, any ideas on what other method might get me the > auto-error-highlighting I want?select( :client, :company_id, options_from_collection_for_select(@companies, :id, :name, selected_value=2), :prompt => "Please select a company..." ) -- We develop, watch us RoR, in numbers too big to ignore.
Thanks, Mark. This seems close. Well, it returns the correct SELECTS but escaped (twice, actually) within the HTML. So, I get... <select id="client_company_id" name="client[company_id]"> <option value="">Please select a company...</option> <option value="<option value="1" selected="selected">Company X</option> "><option value="1" selected="selected">Company X</option></option> <option value="<option value="2">Company Y</option>"><option value="2">CompanyY</option></option> </select> Can the options_from_collection_for_select really exist with the select? On 10/26/05 10:46 AM, "Mark Reginald James" <mrj-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> Paul Welty wrote: > >> collection_select(:client, :company_id, @companies, :id, :name, { >> :selected_value => 2 , :prompt => "Please select a company..." }) >> >> Returns a functioning SELECT element, but it won¹t select the second item. >> (BTW, using the selected_value as a string doesn¹t work either) >> >> Am I doing something wrong, or is this impossible? >> >> If impossible, any ideas on what other method might get me the >> auto-error-highlighting I want? > > select( :client, :company_id, > options_from_collection_for_select(@companies, :id, :name, > selected_value=2), > :prompt => "Please select a company..." )