Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
Cool, just started using rails and was frustrated with date input. Thanks for this post!
Hi Balaji
Are you saying that your select option for years only goes as far as 1971? If so, is the date currently selected 1976? If this is what's happening it's because Rails defaults to a five-year 'radius' around the current year in date_select.
You can work around this by adding the :start_year option. Something like this:
(Date.today.year -75) %>
This would show a range of years for selection between 1933 and 2013 (five years into the future). But this might not quite be what you want, because the dates would be displayed in ascending order from 1933. You want the dates in descending order. And you know that none of your employees will be under 15, so you can omit the most recent years. This is how you'd do it:
(Date.today.year - 15), :end_year => (Date.today.year - 75) %>
Or you could avoid all these issues and make life a lot easier for your users with Nathaniel Brown's Datetime Toolbocks. Check it out at http://datetime.toolbocks.com/
Hi
I am using date_select for one of my form , i having an issue with it i am not able to update to a date prior to 1971 ( year ) , is there any patch available for this.
I am using ruby - 1.8.6 rails - 1.2.6
