datetime_select 上的值为零? [英] Nil value on datetime_select?
问题描述
当将 <%= f.datetime_select :start %> 用于新"对象表单时,如何设置选项以不选择默认日期而是选择 nil/null 值?相关模型中的字段可以选择为空,但默认情况下 datetime_select 控件没有空选项.
我想你想要:
f.datetime_select :start, :include_blank =>真实
当 start
为 nil 时,字段将选择空白选项.这也允许用户不输入日期.
有关详细信息,请参阅有关 date_select 的文档.>
When using <%= f.datetime_select :start %> for a "new" object form, how can you set the options to not select a date by default but rather a nil/null value? The field in the related model can optionally be null but by default the datetime_select control doesn't have a null option.
I think you want:
f.datetime_select :start, :include_blank => true
When start
is nil, the fields will select the blank option. This also allows users to not enter a date.
See the documentation for date_select for details.
这篇关于datetime_select 上的值为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!