I am having some trouble getting datetime_select to work in my form. I can get it to EITHER Set the default date OR allow prompts, but not both. What I really want is something like
2011 June 18 hour minute
where the default values for the day, month and year popups are set, but the default values for the hour and minute are not. If I use this code:
<%= f.datetime_select:start_time,
:default => Time.now,
:prompt => {:hour => "hour", :minute => "minute"} %>
I get the values
2006 January 1 hour minute
If I don't set the prompts, the default shows just fine.
<%= f.datetime_select:start_time, :default => Time.now %>
yields
2011 June 18 23:53
I have also tried setting just the parts of the default that I want
<%= f.datetime_select:start_tim开发者_开发技巧e,
:default =>{:year=>Time.now.year,:month=>Time.now.month,:day=>Time.now.day},
:prompt => {:hour => "hour", :minute => "minute"} %>
and it does the same thing as just setting the whole default to Time.now.
Any thoughts? Is it really not supported to have prompts and a default?
Thanks for your help.
In my knowledge you should probably try something on the following lines :
<%= f.datetime_select :start_time, :default => Time.now.strftime('%Y %B %d %H %M') %>
精彩评论