One thing I haven't figured out or found an answer to is if I create a
select tag from a database table, how can I have an option for "Please
select" or "choose" or whatever -
I know i can do something like :include_blank => true. That works
fine. I came across an option like :include_blank_text => 'something',
but that didn't work.
Anyone know how to do it ?
Stuart
Add that option manually.
@options = [['Select from list', '']] + Product.find(:all,
...).map{|p| p.name, p.id}
options_for_select(@options, ...)
I can't seem to make this work -
This is what I have currently -
<label for="<%= form_name -%>_<%= :state -%>">State</label><br />
<% @states = State.find(:all, :order => "name").map {|s| [s.name, s.id]} %>
<%= f.select("state" , @states, "include_text" => 'please' ) %><br />
Adding in the options seems to throw some parsing errors.
Stuart
Okay, working now as;
<label for="<%= form_name -%>_<%= :state -%>">State</label><br />
<% @states = State.find(:all, :order => "name").map {|s| [s.name, s.id]} %>
<%= f.select("state" , [['Please Select', '']] + @states ) %><br />
Does anyone know what the 'prompt' option is in a select ? I came
across mention of this in this patch message -
http://dev.rubyonrails.org/ticket/3858
Haven't found anything on it though.
Stuart
<% @states = [['Please', '' ]] + State.find(:all, :order => "name").map {|s| [s.name, s.id]} %>
<%= f.select("state" , @states ) %>
Dark Ambient wrote: