以下代码按预期工作,使用 @the_date 作为默认选定日期。
<%= date_select("the_date", "", :default => @the_date ) %>
但是,在没有日期的情况下,它需要显示空白。以下代码显示空白,但即使定义了日期,也会强制默认选择为空白。
<%= date_select("patient_details[birth_date]", "", { :default => @the_date, :include_blank => true } ) %>
如何将默认选择设置为日期,如果日期为零,则设置为空白?
在 Rails 3.07 中工作。
谢谢。
最佳答案
rails ignores your :default
如果您也使用 :include_blank
或 :prompt
.
IMO 这是一个错误,但我们去了。
关于ruby-on-rails - 如何在 Rails 的 date_select 中同时使用空白日期和默认日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7526318/