Tuesday, September 8, 2009

How to Fix When calendar_date_select Isn't Saving the Date or DateTime

Ran into an issue for a while where calendar_date_select wasn't saving the DateTime specified.

In this case we had a date picker:

<%= f.calendar_date_select :something_occurs_at, :popup => :force, :size => 10, :time => false %>
<%= hidden_field_tag 'something_occurs_at','',:id => "clear_something_occurs_at" %>
<%= error_message_on :something, :something_occurs_at %>

The trick was the value following hidden_field_tag. We had 'something_occurs_at' set to 'something[something_occurs_at]', which was appropriate for another case but not for this one.

If nothing else, that value is something to focus on if you have similar issues. For info or support on calendar_date_select, go to their site.

No comments: