开发者

Formtastic Time fields to read as HH::MIN(00 & 30) instead of two selects?

I'm looking for a way to override the Fo开发者_JAVA技巧rmtastic plug-in in rails so that times are shown as a single drop-down with minutes represented in half hour increments. Instead of the two drop-downs one for hour and one for minutes.

Ex 1:00 AM, 1:30 AM, 2:00 AM, etc?

any help would be appreciated.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜