Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3: Simple form start date

Im using simple form in my app to get the users birthday.

It is set (and I want to keep it this way) to go back to year 1900 but I was wondering if there is a way to have the default start be like 1950 (they can still scroll back to older if they need) so most users dont have to scroll so far to get to their age.

  <%= f.input :date_of_birth, :as => :date, :start_year => 1900,
    :end_year => Date.today.year - 12,
    :order => [ :day, :month, :year], :required => true %>

Thanks!

like image 866
js111 Avatar asked Jul 08 '12 20:07

js111


1 Answers

You can just switch the :start_year value with the :end_year value to have

 <%= f.input :date_of_birth, :as => :date, :start_year => Date.today.year - 12,
:end_year => 1900,
:order => [ :day, :month, :year], :required => true %>

As the :start_year and :end_year is just the way you display the year...

like image 161
phron Avatar answered Oct 05 '22 01:10

phron