Reputation: 9570
I have a form in Ruby on Rails that uses methods like f.label, f.textarea
I want to also use the same methods for f.select_datetime, but it doesn't work. How can I get a select_datetime input to work with the normal form methods?
<tr>
<td><%= f.label :price %>:</td>
<td>
<%= f.text_field :price, :placeholder => "price (decimal format, e.g. 12.99 or 19)" %>
</td>
</tr>
<tr>
<td><%= f.label :ends_at %>:</td>
<td>
<%= select_datetime Time.now + 4.days %>
</td>
</tr>
Upvotes: 0
Views: 1002
Reputation: 12320
best for datetime select
<%= f.datetime_select(:offer_end, :default => { :hour => 23, :minute => 59 }) %>
Refer this link Datetime select
Upvotes: 0
Reputation: 2653
You can use like this:
<%= f.datetime_select(:field_name, :default => { Time.now + 4.days }) %>
Upvotes: 0
Reputation: 38645
You can use <%= f.datetime_select Time.now + 4.days %>
Here is the documentation for it: http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-datetime_select
Upvotes: 1