Configure datetime field in Rails with simple_form

I am using Rails 3.2.14, MySQL and simple_form for my application.

I have a column field notification_timeset to datetimeand I configured it as a text field similar to this in_create_form.erb

<%= f.input :notification_time, :input_html => { :value => DateTime.now.strftime("%d/%m/%Y - %H:%M %p")}, :as => :string %>

This will result 08/10/2013 - 13:50 PMin a browser.

I _update_form.erbonly have s <%= f.input :notification_time, :as => :string %>, and this leads to2013-10-08 13:50:00 -0400

How to make sure what I can get 08/10/2013 - 13:50 PMwhen updating the form?

+4
source share
1 answer

Well, you never tweak how it looks.

DateTime.now.strftime("%d/%m/%Y - %H:%M %p"), .

, _update_form.erb , , .

, @form.

: <%= f.input :notification_time, :value => @form.notification_time.strftime("%d/%m/%Y - %H:%M %p"), :as => :string %>... - .

+5

All Articles