yellowreign
yellowreign

Reputation: 3638

Rails Simple_Form Add Years to Date Field

I'm my Rails app, one of the fields for my User model is Date of Birth (dob). The problem I'm having with Simple_Form is that the default dropdown only goes back until 2010 and I need it to go back much further.

Is there a way I can show additional years?

<%= simple_form_for(@user) do |f| %>
  <%= f.input :dob, order: [:month, :day, :year]
<%= end %>

Upvotes: 3

Views: 1376

Answers (1)

Andrey Deineko
Andrey Deineko

Reputation: 52357

You can specify the start_year and end_year:

= f.input :dob,
  start_year: Time.now.year - 100,
  end_year: Time.now.year - 18,
  order: %i(day month year)

Checkout docs for more info on options.

Upvotes: 5

Related Questions