BUGFIX Limit 'showcalendar' javascript option to DateField instances (rather than applying to all available) (from r107785)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112693 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-18 22:22:56 +00:00
parent fd6fa62388
commit 40bc9ced5d
2 changed files with 7 additions and 2 deletions

View File

@ -205,7 +205,7 @@ class DateField extends TextField {
if(Validator::get_javascript_validator_handler() == 'none') return true;
if($this->showSeparateFields) {
if($this->getConfig('dmyfields')) {
$error = _t('DateField.VALIDATIONJS', 'Please enter a valid date format (DD/MM/YYYY).');
$error = 'Please enter a valid date format (DD/MM/YYYY) from dmy.';
$jsFunc =<<<JS
@ -517,7 +517,11 @@ class DateField_View_JQuery {
if($this->getField()->getConfig('showcalendar')) {
// Inject configuration into existing HTML
$format = self::convert_iso_to_jquery_format($this->getField()->getConfig('dateformat'));
$this->getField()->addExtraClass(str_replace('"', '\'', Convert::raw2json(array('dateFormat' => $format))));
$conf = array(
'showcalendar' => true,
'dateFormat' => $format
);
$this->getField()->addExtraClass(str_replace('"', '\'', Convert::raw2json($conf)));
}
}

View File

@ -1,6 +1,7 @@
(function($) {
$('.field.date input.text').live('click', function() {
var holder = $(this).parents('.field.date:first'), config = holder.metadata();
if(!config.showcalendar) return;
if(config.locale && $.datepicker.regional[config.locale]) {
config = $.extend(config, $.datepicker.regional[config.locale], {});