I am using Simple_Form Gem. I have created date_of_birth:date field on Student model.

So my students form is:

<%= f.date_select :date_of_birth, label: "Date of Birth" %>

When I am going to pick the year in the form, it's just listing year from 2014 to 2024. But I want it should show 1965 - today.

So how can I set start year and end year and where?

1 Answers

CAmador On

As the docs state: Simple Form inputs accept the same options as their corresponding input type helper in Rails:

<%= simple_form_for @user do |f| %>
  <%= f.input :date_of_birth, as: :date, start_year: Date.today.year - 90,
                              end_year: Date.today.year - 12, discard_day: true,
                              order: [:month, :year] %>
  <%= f.button :submit %>
<% end %>