Forum: Ruby on Rails Option on select form helper to customize "Select" text?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2009-02-09 21:06
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
Af2ce6689213fdb78913a9662b18da6b?d=identicon&s=25 Rick (Guest)
on 2009-02-09 23:11
(Received via mailing list)
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:

<h1>New thing</h1>

<% form_for(@thing) do |f| %>
  <%= f.error_messages %>
.
.
  <p>
    <%= f.label :when %><br />
    <%= f.datetime_select :when %>
  </p>

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

On Feb 9, 10:06 am, Wes Gamble <rails-mailing-l...@andreas-s.net>
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2009-02-10 00:02
Rick,

Thanks, but not what I'm looking for.

Wes
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-10 00:51
(Received via mailing list)
On Feb 9, 8:06 pm, Wes Gamble <rails-mailing-l...@andreas-s.net>
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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2009-02-10 01:24
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
This topic is locked and can not be replied to.