2010-08-31 207 views
2

在表单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 
+0

两个代码是完全执行,并默认到1950年我woud喜欢知道你期待什么,请详细说明问题。 – Rohit 2010-08-31 06:06:03

+0

我希望今年默认为当前年份 - 10。 – 2010-08-31 07:19:09

回答