views:

134

answers:

1

I'm looking for a way to override the Formtastic 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.

+1  A: 

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

ClaudioA
Thanks for the link... not exactly what I'm looking for, but It set me on the right path... I'm going to implement hidden fields and use a dummy drop-down with a standard select pre-populated with my time choices, then have javascript populate the needed fields.
Nick Faraday