Bootstrap datepicker default value simple_form_for

后端 未结 4 1086
一整个雨季
一整个雨季 2020-12-17 04:15

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, i         


        
4条回答
  •  温柔的废话
    2020-12-17 05:10

    You can also use this gem: https://github.com/Nerian/bootstrap-datepicker-rails

    on your gemfile.rb

    gem 'bootstrap-datepicker-rails'
    

    then bundle install and restart rails server

    then add this line to app/assets/stylesheets/application.css

     *= require bootstrap-datepicker
    

    and add this line to app/assets/javascripts/application.js

     //= require bootstrap-datepicker
    

    and to use this in your form:

    <%= f.text_field :payment_date, :id => "datepicker", :value => Date.today %>
    

    and add this javascript on the same view of your form

    
    

提交回复
热议问题