Search code examples
ruby-on-railsrubyruby-on-rails-3simple-form

Bootstrap datepicker default value simple_form_for


I am using the bootstrap date picker to enable selection of dates in a form using simple_form_for. For example

  <%= f.input :payment_date, as: :string, input_html: { class: "datepicker" } %>

My date picker uses the format of dd-mm-yyyy

I would like to set today's date as the default value in the form using simple_form_for, any ideas on how I can do that?


Solution

  • <%= f.input :payment_date, as: :string, input_html: { class: "datepicker", value: Time.now.strftime('%d-%m-%Y') } %>   
    

    Another format to it is: (working with active admin gem)

    f.input :date, as: :date_picker, :input_html => { :value => Date.today}