Browse files

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
  • Loading branch information...
1 parent fd6fa62 commit 40bc9ced5d2d013ca4c5cbb0287ac4abe88a5cee @sminnee sminnee committed Oct 18, 2010
Showing with 7 additions and 2 deletions.
  1. +6 −2 forms/DateField.php
  2. +1 −0 javascript/DateField.js
View
8 forms/DateField.php
@@ -205,7 +205,7 @@ function jsValidation() {
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 @@ function onBeforeRender() {
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
1 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], {});

0 comments on commit 40bc9ce

Please sign in to comment.