[英]In Rails how can I change the display method of my drop down list?
I'm using Simple Forms in Rails 4.2. 我在Rails 4.2中使用简单表单。 I have the following date selector for birth dates on my form page.
我的表单页面上有以下出生日期选择器。 I want to display the months in the selector drop down list in the following format,
1-January
, 2-February
, 3-March
... Instead of January
, February
, March
. 我想以以下格式在选择器下拉列表中显示月份,即
1-January
, 2-February
, 3-March
...而不是January
, February
, March
。 How can I do this? 我怎样才能做到这一点?
<%= f.input :birth_date, as: :date, start_year: Time.now.year - 15, end_year: Time.now.year - 75,
order: [:month, :day, :year], default: nil, label: false, include_blank: true,
input_html: { style: 'margin: 15px 0px; display: inline-block; width: 110px;' } %>
通过应用以下两个选项之一,可以获得所需的结果:
add_month_numbers: true
month_format_string: "%<number>02d-%{name}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.