Buy Now
Sign in

Datepicker Custom Tutorial checkin checkout+custom js

mdma , October 09 2015

Maybe not perfect but i want to share my solution / i use a bootstrap3 template so fa-icons get loaded there
style for chronoforms none:
get the files: to libraries/cegcore/assets/dp_bs3/
1.) implementing html with 2 custom fields in designer:

				<div class=" Checkin ">
<label for="Checkin" class="gcore-label-top">##Checkin##</label> change in locales ##Checkin##=...
<div class="input-group date Checkin">
<input name="Checkin" id="Checkin" class=" form-control" type="text" /> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>

				<div class=" Checkout ">
<label for="Checkout" class="gcore-label-top">##Checkout##</label> ...change in locales ##Checkout##=...
<div class="input-group date Checkout">
<input name="Checkout" id="Checkout" class=" form-control" type="text" /> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>

2.)in Setup before Html (render Form) make a custom code like:
$lang =& JFactory::getLanguage();
$tag =& $lang->getTag();
$scripturl = "libraries/cegcore/assets/dp_bs3/js/locales/bootstrap-datepicker.$tag.min.js";
$scripturl2= JURI::root().'libraries/cegcore/assets/dp_bs3/';
$scripturl3 = "libraries/cegcore/assets/dp_bs3/js/dp.$tag.js";
$jdoc =& JFactory::getDocument();

i have copied the files to libraries/cegcore/assets/dp_bs3. the dp.$tag.js is for language dependent loading. of custom js files i created like this: for example en-GB:/libraries/cegcore/assets/dp_bs3/js/dp.en-GB.js for other language you copy the script rename it to dp.xx-XX.js and change the language in the script. for further config look here:
jQuery(document).ready(function ($) {
$(function () {
var checkout = $('.Checkout').datepicker({weekStart: 1, todayHighlight: false, language:'en-GB', autoclose: true, format: 'dd-mm-yyyy'});
$('.Checkout').attr('disabled', 'disabled');
var checkin = $('.Checkin').datepicker({weekStart: 1, todayHighlight: true,
autoclose: true,
format: 'dd-mm-yyyy',
startDate: "+0d",
      endDate: ''
}).on('changeDate', function(event) {
var newDate = new Date(
newDate.setDate(newDate.getDate() + 1)
checkout.datepicker("setStartDate", newDate);
      checkout.datepicker("update", newDate)


that way checkout is alway 1 day after checkin automatically selected...js is not perfect (focus doesnt work) ..

in email template you have to call this fields custom with custom email like they arent automatically there
				##Checkin##: {Checkin} <br> 
##Checkout##: {Checkout}

I spent alot of time with the datepicker recherching i liked the config of eternicode and i needed two dates in the end
...i also recommend everyone looking into this one: