要实现AM PM功能

时间:2012-05-02 10:08:23

标签: ruby-on-rails

在我的应用程序中,我希望实现AM和PM功能。用户不应该自己输入。我有一个文本框,用户应该只输入数字我也想添加时间选择器。

  %li
    %label{:for => "start_time"}Start_time<em>*</em>
    = f.text_field :start_time, :required => "required", :autofocus => true


  %li
    %label{:for => "end_time"}End_time<em>*</em>
    = f.text_field :end_time, :required => "required", :autofocus => true

1 个答案:

答案 0 :(得分:0)

实际上你可以使用time_select方法&amp;做这样的事情:

time_select("event", "start_time", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'})

time_select("event", "end_time", :prompt => {:hour => 'Choose hour', :minute => 'Choose minute', :second => 'Choose seconds'})

希望它有所帮助!