Fresh
Fresh

Reputation: 767

How to update datetime field

What is the best way to update a datetime field in a form.

I have a form and need to update both the date and the time.

I need to update the date with a date_select and then update the time using a time_select

I only have 1 field in my database. Event:date

I need to save the date in one field and then update the same field but add the date.

It has to be that way for the user to pick them separately. But it has to be one table in the database for the calendar.

--------------Form
Select Date :  Dateselect  saving to db:field  :Starttime
Select Time :  Timeselect  saving to db:field  :Starttime

Upvotes: 2

Views: 3216

Answers (2)

Valera
Valera

Reputation: 98

Try using the calendar_date_select gem. It lets you select date and/or time with one control. http://code.google.com/p/calendardateselect/

Upvotes: 0

jonnii
jonnii

Reputation: 28312

There's select_datetime for this:

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001701

Upvotes: 1

Related Questions