Dylan Markow
2006-Jan-08 07:11 UTC
Options_from_collection_for_select -> Multiple fields in display
The following code shows a list of the users, with username being each person''s initials (mine would be DM). <%= options_from_collection_for_select @users,"id","username" %> However, I''d like to have the display of the SELECT box be "DM - Dylan Markow" instead of "DM." Is this possible using options_from_collection_for_select, or will I need to manually loop through the entries myself? Thanks! _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Eric Sloane
2006-Jan-08 22:32 UTC
[Rails] Re: Options_from_collection_for_select -> Multiple fields in display
Dylan - I asked this question recently and Mark JAmes answered; Eric Sloane wrote: > How do you concatenate a first_name, last_name as the text method for OFCFS? Damned if I can do it without error. Is it in the original select for the collection? Define an instance method in the model that returns first_name + last_name and use that as the text method in ofcfs. And that works fine. Cheers, Eric. Dylan Markow wrote:> The following code shows a list of the users, with username being each > person''s initials (mine would be DM). > > <%= options_from_collection_for_select @users,"id","username" %> > > However, I''d like to have the display of the SELECT box be "DM - Dylan > Markow" instead of "DM." Is this possible using > options_from_collection_for_select, or will I need to manually loop > through the entries myself? > > Thanks! > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails