日期选择:默认选择年份
问题描述:
在表单1上,我有一个formtastic
date_select字段。日期选择:默认选择年份
= f.input :date_from, :discard_day => true,
:discard_month => true,
:order => [:year],
:start_year => 1950,
:end_year => Date.today.year,
:include_blank => false
当表单被呈现时,year
下拉框默认为1950。
在形式2中,我有另一个formtastic
date_select字段。
= f.input :date_from, :discard_day => true,
:order => [:month, :year],
:start_year => 1950,
:end_year => Date.today.year,
:include_blank => false
当形式呈现,在year
下拉框默认为2000
你怎么解释这种现象?理想情况下,我希望年份字段默认为10 years ago
。
P.S: 设置默认值没有区别。
:default => Date.today
答
你试过:
:selected => Date.today.year - 10
在RDoc的为formtastic来看,应该工作:http://rdoc.info/github/justinfrench/formtastic/master/Formtastic/SemanticFormBuilder:date_input
+0
谢谢,这工作。 – 2010-08-31 17:28:25
两个代码是完全执行,并默认到1950年我woud喜欢知道你期待什么,请详细说明问题。 – Rohit 2010-08-31 06:06:03
我希望今年默认为当前年份 - 10。 – 2010-08-31 07:19:09