如何在rails中为date_select指定占位符?

时间:2014-02-26 12:58:49

标签: ruby-on-rails formtastic

我有haml使用formtastic来指定date_select输入(年,月,日):

  = f.input :birthday,
    start_year: 1900,
    end_year: time.now.year-18,
    input_html: { class: 'select2' }

使用父元素类作为占位符呈现3个选择框:

<select ... placeholder=".span1">

如何指定占位符?年;月;日就足够了。

1 个答案:

答案 0 :(得分:1)

根据Formtastic Documentation

<%= f.input :publish_at, :as => :date_select, :labels => { :year => "Year", :month => "Month", :day => "Day" } %>

<强> [编辑]

如果使用formtastic-bootstrap gem,您可能需要使用code上使用的:placeholder。 但是,master :placeholder选项未实现,而是使用TODO评论。