Option on select form helper to customize "Select" text?


#1

All,

Is there any built-in way in the “select” form helper to display
something other than “Select” in the :include_blank option?
Specifically, for a date helper, would like to show “Month”, “Day”,
“Year” respectively for those options in 3 selects.

Thanks,
Wes


#2

Try this:

script/generate scaffold Thing name:string when:datetime text:body

You’ll see:

In migration:

create_table :things do |t|
  t.string :name
  t.datetime :when
  t.text :body
end

In view:

New thing

<% form_for(@thing) do |f| %>
<%= f.error_messages %>
.
.

<%= f.label :when %>
<%= f.datetime_select :when %>

start your server and check out: localhost:3000/things/new

On Feb 9, 10:06 am, Wes G. removed_email_address@domain.invalid


#3

Rick,

Thanks, but not what I’m looking for.

Wes


#4

On Feb 9, 8:06 pm, Wes G. removed_email_address@domain.invalid
wrote:

All,

Is there any built-in way in the “select” form helper to display
something other than “Select” in the :include_blank option?
Specifically, for a date helper, would like to show “Month”, “Day”,
“Year” respectively for those options in 3 selects.

If the :include_blank option is a string then that is used for the
blank option. There’s also the :prompt option. I do recall that
support of this with the date_select stuff was only added recently.

Fred


#5

Fred,

Thanks for the info. I neglected to mention that this is on Rails 1.2.6
(please no one “helpfully suggest” that I upgrade - thanks ;]), so these
options are not available. It’s fine - I won’t die.

One further question, if you use a “unified” helper like date_select in
the current v. of Rails (obviously), can you set different promopts for
each component input field of the date?

Wes