Limit list of minutes to datetime_select

I am using Rails in a web application.
I would like to know if datetime_select

only two options can be reported in the minutes dropdown? Options 00 and 30.

I have below code:

<p><label for="command_date_to_execute">Date to Run</label><br/>
<%= datetime_select 'command', 'date_to_run', :discard_minute => true  %>:
<%= select 'command', 'date_to_run', ['00', '30'] %>
</p>

      

Browser source creates:

<select id="command_date_to_run" name="command[date_to_run]">
<option value="00">00</option>
<option value="30">30</option>
</select>

      

But what I really need is below (with 5i in the generated HTML):



<select id="command_date_to_execute_5i" name="command[date_to_execute(5i)]">
<option value="00">00</option>
<option value="30">30</option>
</select>

      

Please, help

+3


source to share


1 answer


If you only want 00 and 30 for minutes, you can do the following:

= f.datetime_select(:leave_end, :start_year => 2011, :ampm => true, :default => 0.days.from_now.in_time_zone(@timezone), :discard_minute => true) %span : 
= f.select('req_sess_start(5i)', ['00', '30'])

      

This can lead to page validation exceptions due to the (possibly) unknown variable req_sess_start (5i). Will work if validation is in progress.



The below will work better, although it won't throw an exception.

= f.datetime_select(:req_sess_start, :start_year => 2011, :ampm => true, :default => 0.days.from_now.in_time_zone(@timezone), :minute_step => 30)

      

+4


source