レールの Formtastic プラグインをオーバーライドして、時間が 30 分単位で分を表す単一のドロップダウンとして表示されるようにする方法を探しています。2 つのドロップダウンの代わりに、1 つは時間用、もう 1 つは分用です。
例: 午前 1:00、午前 1:30、午前 2:00 など?
任意の助けをいただければ幸いです。
レールの Formtastic プラグインをオーバーライドして、時間が 30 分単位で分を表す単一のドロップダウンとして表示されるようにする方法を探しています。2 つのドロップダウンの代わりに、1 つは時間用、もう 1 つは分用です。
例: 午前 1:00、午前 1:30、午前 2:00 など?
任意の助けをいただければ幸いです。
I think that you could give a try to this one: http://labs.perifer.se/timedatepicker/. Its really simple and It will provide you with a drop down to get the desired time.
For example to generate a list of times in half hour increments, you should do something like:
$(".time").timePicker({
show24Hours: false,
step: 30
});
Where .time is the class of your text_field:
<%= your_time_form.text_field :time, :class => "time", :value => time %>
Of course, then in a helper / controller you will need to manipulate this value to build the desired object (maybe a DateTime instance).