User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Ruby section within the Web Development category of DaniWeb, a massive community of 423,120 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,211 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !

collection_select with :selected option

Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 33
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: collection_select with :selected option

  #4  
Apr 14th, 2007
Originally Posted by amithasija View Post
thanx buddy for quick reply,

now i am explaning you the whole scenario.what i have done is ,i have a sample form with collection_select on it with multiple true(suppose five values).on submit selected values goes into database(suppose two) coreesponding to particular id.now when i again open the page i want the values from database comes as selected(two values that are coming from database as highlighted or selected).and thanx for all your help till now and in future.


Ah - I see what you mean now.

Try something like this (for this i'm assuming a person has many jobs):

<%= collection_select 
	:person, 
	:job_ids,
	Job.find(:all),
	:id, 
	:description,
	{},
	:multiple => true,
	:name => 'person[job_ids][]' 
%>
Last edited by pty : Apr 14th, 2007 at 10:17 am. Reason: alignment went funny
Note to self... pocket cup
Reply With Quote  
All times are GMT -4. The time now is 6:37 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC