简体   繁体   中英

Order year in rails date_select

f.date_select(:birthday, prompt: {
                  day: 'Select day', month: 'Select month', year: 'Select year'
                  }, end_year: Time.now.year-13, start_year: 1900, required: true)

It shows start_year first and end_year last: 1900 1901 .. .. 2002

I want 2002 first and 1900 at the bottom of the select box. Couldn't find anything in rails documentation and google. Any help will be appreciated. Thanks

Simply exchanging end_year and start_year will do the trick.

In your case:

f.date_select(:birthday, prompt: {
              day: 'Select day', month: 'Select month', year: 'Select year'
              }, end_year: 1900, start_year: Time.now.year-13, required: true) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM