Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to use DatePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
:
:
//= require admin-lte/plugins/datepicker/bootstrap-datepicker
//= require admin-lte/plugins/datepicker/locales/bootstrap-datepicker.ja
$(document).ready ->
$('#hogeDateDatePicker').datepicker({
format: 'yyyy/mm/dd',
language: 'ja',
todayHighlight: true
});
class HogesController < ApplicationController
def new
@hoge = Hoge.new
end
def create
# something...
if @hoge.save
redirect_to root_path,
flash: { success: 'Succeed in creating data.' }
else
flash.now[:alert] = 'Failed in creating data.'
render 'new', locals: { date: Time.zone.now.strftime('%Y/%m/%d') } # Plz change the variable 'date' as you like
end
end
end
= form_for @hoge, url: hoges_path do |f|
= f.text_field :date,
id: 'hogeDateDatePicker',
class: 'form-control',
placeholder: '2018/01/31',
value: @date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment