0

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>
1
  • can you pleasse show me what the error you got Commented Jul 30, 2013 at 4:54

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

You can use like this:

<%= f.datetime_select(:field_name, :default => { Time.now + 4.days }) %>

Comments

0

best for datetime select
<%= f.datetime_select(:offer_end, :default => { :hour => 23, :minute => 59 }) %>

Refer this link Datetime select

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.