Rails Simple_Form 将年份添加到日期字段
Rails Simple_Form Add Years to Date Field
我是我的 Rails 应用程序,我的 User
模型的字段之一是出生日期 (dob
)。 Simple_Form 我遇到的问题是默认下拉菜单只能追溯到 2010 年,我需要它更进一步。
有没有办法显示额外的年份?
<%= simple_form_for(@user) do |f| %>
<%= f.input :dob, order: [:month, :day, :year]
<%= end %>
您可以指定 start_year
和 end_year
:
= f.input :dob,
start_year: Time.now.year - 100,
end_year: Time.now.year - 18,
order: %i(day month year)
Checkout docs 有关选项的更多信息。
我是我的 Rails 应用程序,我的 User
模型的字段之一是出生日期 (dob
)。 Simple_Form 我遇到的问题是默认下拉菜单只能追溯到 2010 年,我需要它更进一步。
有没有办法显示额外的年份?
<%= simple_form_for(@user) do |f| %>
<%= f.input :dob, order: [:month, :day, :year]
<%= end %>
您可以指定 start_year
和 end_year
:
= f.input :dob,
start_year: Time.now.year - 100,
end_year: Time.now.year - 18,
order: %i(day month year)
Checkout docs 有关选项的更多信息。