mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Allowing global default configuration for DateField, TimeField and DatetimeField
This commit is contained in:
parent
585a8bc784
commit
d93bd49edc
@ -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 @@ class DateField extends TextField {
|
||||
$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 @@ class DateField_View_JQuery {
|
||||
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 @@ class DatetimeField extends FormField {
|
||||
return $this->timeField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FormField
|
||||
*/
|
||||
function getTimezoneField() {
|
||||
return $this->timezoneField;
|
||||
}
|
||||
|
||||
function setLocale($locale) {
|
||||
$this->dateField->setLocale($locale);
|
||||
$this->timeField->setLocale($locale);
|
||||
|
@ -22,13 +22,21 @@ require_once 'Zend/Date.php';
|
||||
* @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
|
||||
*/
|
||||
@ -46,6 +54,8 @@ class TimeField extends TextField {
|
||||
$this->locale = i18n::get_locale();
|
||||
}
|
||||
|
||||
$this->config = self::$default_config;
|
||||
|
||||
if(!$this->getConfig('timeformat')) {
|
||||
$this->setConfig('timeformat', i18n::get_time_format());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user