From 40bc9ced5d2d013ca4c5cbb0287ac4abe88a5cee Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 18 Oct 2010 22:22:56 +0000 Subject: [PATCH] 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 --- forms/DateField.php | 8 ++++++-- javascript/DateField.js | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/forms/DateField.php b/forms/DateField.php index 123e60077..e313d3db2 100755 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -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 =<<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))); } } diff --git a/javascript/DateField.js b/javascript/DateField.js index 05ae32f6c..ee3b8713a 100644 --- a/javascript/DateField.js +++ b/javascript/DateField.js @@ -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], {});