Hello,
I am generating this <select>
<% @humans = Person.find(:all, :order => "name")
collection_select(:news, :person_id, @humans, :id, :name)
%>
How can I add an option where they can choose "no one" with a value of
nil?
Thanks!
jeremy.
Wilson Bilkovich
2005-Sep-09 18:16 UTC
Re: adding an additional option to collection_select
On 9/9/05, jeremy*pinnix <jpinnix.alt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I am generating this <select> > > <%> @humans = Person.find(:all, :order => "name") > collection_select(:news, :person_id, @humans, :id, :name) > %> > > How can I add an option where they can choose "no one" with a value of nil? >Add this after the find, but before the collection_select tag. @humans.unshift(["No one",""]) There are probably numerous other ways to do it, though. --Wilson.
collection_select(:news, :person_id, @humans, :id, :name, { :prompt =>
"no one"})
On 9/9/05, jeremy*pinnix
<jpinnix.alt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello,
>
> I am generating this <select>
>
> <%> @humans = Person.find(:all, :order => "name")
> collection_select(:news, :person_id, @humans, :id, :name)
> %>
>
> How can I add an option where they can choose "no one" with a
value of nil?
>
> Thanks!
> jeremy.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>