Search code examples
ruby-on-railsformtastic

How to specify placeholders for date_select in rails?


I have haml that uses formtastic to specify date_select input (year,month,day):

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

Which renders me 3 select boxes with parent element class as a placeholder:

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

How to specify placeholders? Year;Month;Day would be good enough.


Solution

  • According to Formtastic Documentation:

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

    [Edit]

    If formtastic-bootstrap gem is used, you probably need to use :placeholder as it is used on the code. Though, on master the :placeholder option is not implemented, with a TODO comment instead.