[TYPO3-dev] ExtJS date pickers and date ranges (working prototype maybe for Core?)
Stefano Cecere
scecere at krur.com
Thu Oct 14 15:35:18 CEST 2010
hi
i just modified the date pickers to support (minimal) date ranges
(i had the date2cal extension patched for this.. but moving to 4.4
date2cal doesn't work well anymore, and i wanted all native)
the patch is very simple, and maybe it could be expanded to propose it for
Core 4.5 ?
i did this:
in file t3lib/class.t3lib_tceforms.php i added a custom class to the date
input element (in my case "fromTomorrow', since i'm interested in blocking
selection of past dates)
if (in_array('date', $evalList)) {
$inputId = uniqid('tceforms-datefield-');
// XCLASS start
if ($config['range']['lower'] > 0 ) {
$range = ' fromTomorrow';
}
$cssClasses[] = 'tceforms-textfield tceforms-datefield'.$range;
// XCLASS end
$fieldAppendix = t3lib_iconWorks::getSpriteIcon(
'actions-edit-pick-date',
array(
'style' => 'cursor:pointer;',
'id' => 'picker-' . $inputId
)
);
and file t3lib/js/extjs/tceforms.js cehcks for that class and adds native
ExtJS minDate value
convertDateFieldsToDatePicker: function() {
var dateFields = Ext.select("input[id^=tceforms-date]");
dateFields.each(function(element) {
var index = element.dom.id.match(/tceforms-datefield-/) ? 0 : 1;
var format = TYPO3.settings.datePickerUSmode ?
TYPO3.settings.dateFormatUS : TYPO3.settings.dateFormat;
var datepicker = element.next('span');
// XCLASS: added minDate option
var minDate = (element.dom.className.match(/fromTomorrow/)) ? new
Date().add(Date.DAY, 1) : null;
var menu = new Ext.menu.DateMenu({
id: 'p' + element.dom.id,
format: format[index],
value: Date.parseDate(element.dom.value, format[index]),
minDate: minDate,
handler: function(picker, date){
var relElement = Ext.getDom(picker.ownerCt.id.substring(1));
relElement.value = date.format(format[index]);
it should be easy to pass both lower and upper ranges (as normally
defined in TCA) putting them as classes of the input element, and then
modify the JS to use those values.
what do you think?
could it be a useful core feature?
stefano
--
____ ___ __ _ ______________________
Stefano Cecere
krur.com - multimedia
More information about the TYPO3-dev
mailing list