Hi All, I am new to RT world.
In Custom Fields, I can add a field using "Select Date’ type - as I want to capture a date of birth.
However, when used during ticket creation, the date selector defaults to a date range of 10 years past / 10 years future, and there is no way to select an older date; unless I first select say a date from 2012 - at which point the selector range is then ± 10 years from that point.
I cannot find anything in field properties / system config to set or change this behaviour; also cannot find anything in previous forum questions.
Can anyone shed any light on how I can change this behaviour?
Thanks, Colm
Hey,
Huh, interesting, I hadn’t noticed this before!
You can just type in the date that you want into the field, without using the picker.
I’ve just had a bit of a dig. The date selector is the Datepicker widget from jQuery. The default range is +/- 10 years, see: Datepicker Widget | jQuery UI API Documentation . This is instantiated within RT in share/static/js/util.js in the initDatePicker function. The simple approach to allow a broader range of years is to modify the opts hash to have “yearRange: c-110:c+10,” (or whatever). A better approach would be to add support when creating the CustomField to specify the year range.
Cheers,
Andrew
Thanks Andrew - well spotted and traced to source.
For anyone else with same issue, I modified the /share/static/js/util.js file -
Modified the original var opts declaration which was…
var opts = {
dateFormat: 'dd-mm-yy',
constrainInput: false,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
showOn: 'none',
selectOtherMonths: true,
onClose: function() {
jQuery(this).trigger('datepicker:close');
}
… to become
var opts = {
dateFormat: 'dd-mm-yy',
constrainInput: false,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
showOn: 'none',
selectOtherMonths: true,
yearRange: '1900:2100',
onClose: function() {
jQuery(this).trigger('datepicker:close');
}
…so basically adding the option to have the date picker extend from 1900 - 2100; these working for my data scenario.
As always, then clear the mason cache (delete all content of /opt/rt5/var/mason_data/obj folder) and restart apache (command line “service apache2 restart”) - as the js files are cached, that will trigger sending the updated util.js file to the browser on next connect.
Colm
2 Likes