Permalink
Browse files

ENHANCEMENT Allowing global default configuration for DateField, Time…

…Field and DatetimeField
  • Loading branch information...
1 parent 585a8bc commit d93bd49edc4ce814d052bc30de8db5a69fbbeb6c @chillu chillu committed Sep 26, 2011
Showing with 36 additions and 5 deletions.
  1. +9 −2 forms/DateField.php
  2. +15 −1 forms/DatetimeField.php
  3. +12 −2 forms/TimeField.php
View
@@ -70,7 +70,7 @@ class DateField extends TextField {
/**
* @var array
*/
- protected $config = array(
+ static $default_config = array(
'showcalendar' => false,
'jslocale' => null,
'dmyfields' => false,
@@ -80,6 +80,11 @@ class DateField extends TextField {
'min' => null,
'max' => null,
);
+
+ /**
+ * @var array
+ */
+ protected $config;
/**
* @var String
@@ -98,6 +103,8 @@ function __construct($name, $title = null, $value = null, $form = null, $rightTi
$this->locale = i18n::get_locale();
}
+ $this->config = self::$default_config;
+
if(!$this->getConfig('dateformat')) {
$this->setConfig('dateformat', i18n::get_date_format());
}
@@ -711,4 +718,4 @@ static function convert_iso_to_jquery_format($format) {
return preg_replace($patterns, $replacements, $format);
}
}
-?>
+?>
@@ -43,13 +43,20 @@ class DatetimeField extends FormField {
/**
* @var array
*/
- protected $config = array(
+ static $default_config = array(
'datavalueformat' => 'YYYY-MM-dd HH:mm:ss',
'usertimezone' => null,
'datetimeorder' => '%s %s',
);
+
+ /**
+ * @var array
+ */
+ protected $config;
function __construct($name, $title = null, $value = ""){
+ $this->config = self::$default_config;
+
$this->dateField = new DateField($name . '[date]', false);
$this->timeField = new TimeField($name . '[time]', false);
$this->timezoneField = new HiddenField($this->Name() . '[timezone]');
@@ -179,6 +186,13 @@ function getTimeField() {
return $this->timeField;
}
+ /**
+ * @return FormField
+ */
+ function getTimezoneField() {
+ return $this->timezoneField;
+ }
+
function setLocale($locale) {
$this->dateField->setLocale($locale);
$this->timeField->setLocale($locale);
View
@@ -22,14 +22,22 @@
* @subpackage fields-datetime
*/
class TimeField extends TextField {
-
- protected $config = array(
+
+ /**
+ * @var array
+ */
+ static $default_config = array(
'timeformat' => 'HH:mm:ss',
'use_strtotime' => true,
'datavalueformat' => 'HH:mm:ss'
);
/**
+ * @var array
+ */
+ protected $config;
+
+ /**
* @var String
*/
protected $locale = null;
@@ -46,6 +54,8 @@ function __construct($name, $title = null, $value = ""){
$this->locale = i18n::get_locale();
}
+ $this->config = self::$default_config;
+
if(!$this->getConfig('timeformat')) {
$this->setConfig('timeformat', i18n::get_time_format());
}

0 comments on commit d93bd49

Please sign in to comment.