-
-
Save duskohu/5955986 to your computer and use it in GitHub Desktop.
Nextras\Forms - DatePicker for twitter bootstrap (http://www.malot.fr/bootstrap-datetimepicker/)
add input-append icons style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$form->addDatePicker('date', 'Date') | |
->setDefaultValue(new DateTime()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function ($) { | |
$('.date, .datetime-local').each(function (i, el) { | |
el = $(el); | |
var input = false; | |
if (!el.parent().hasClass('date')) { | |
if (el.find('input[type=date]')) { | |
input = el.find('input[type=date]'); | |
input.get(0).type = 'text'; | |
input.removeClass('date'); | |
} else { | |
el.get(0).type = 'text'; | |
} | |
el.get(0).type = 'text'; | |
el.datetimepicker({ | |
startDate: el.attr('min'), | |
endDate: el.attr('max'), | |
weekStart: 1, | |
minView: el.is('.date') ? 'month' : 'hour', | |
format: el.is('.date') ? 'd. m. yyyy' : 'd. m. yyyy - hh:ii', | |
autoclose: true | |
}); | |
if (input) { | |
input.attr('value') && el.datetimepicker('setValue'); | |
} else { | |
el.attr('value') && el.datetimepicker('setValue'); | |
} | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="{$form->getElementPrototype()->id}-date-pair" class="control-group"> | |
{label date/} | |
<div class="controls"> | |
<div class="input-append date"> | |
{input date} | |
<span class="add-on"><i class="icon-remove"></i></span> | |
<span class="add-on"><i class="icon-calendar"></i></span> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment