Nil value on datetime_select?

后端 未结 2 1585
悲哀的现实
悲哀的现实 2021-01-17 14:24

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 i

2条回答
  •  我在风中等你
    2021-01-17 15:11

    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.

提交回复
热议问题