Rails -- Cant set value for date_select in form
Posted
by ChrisWesAllen
on Stack Overflow
See other posts from Stack Overflow
or by ChrisWesAllen
Published on 2010-06-05T17:31:53Z
Indexed on
2010/06/05
17:32 UTC
Read the original article
Hit count: 203
I'm pulling data from an API where the date data comes in as "2008-02-11 00:00:00 "
I would like that data to go into my form within the date_select as a value so I can view it correctly before I add it into my database.
The view looks like
<%= f.label :start_date %><br />
<%= f.date_select :start_date, :value => " #{@stdate[idx]} " %>
The object is actually an array of dates since I'm doing this action several times do thats why the [idx] is there; serving as an index.
<%= @stdate[idx] %> ends up outputting "2008-02-11 00:00:00 " but the fields for the date_select helper only outputs the current date "2010" "June" "5" in those dropdown date selects fields...
Do I need to set the values of the Year, Month, and Date Individually? I have Chronic and tried to parse the object before using it as a value for the date_select and that didnt work either.
Any ideas?
© Stack Overflow or respective owner