Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 720
zurik Avatar asked Nov 28 '22 21:11

zurik


1 Answers

<%= 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}
like image 105
sites Avatar answered Dec 10 '22 04:12

sites