mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FEATURE: added ability to define a default configuration set for date field. PATCH via gigtech. Fixes (#6131).
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114816 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
21f84c9513
commit
1ca5ea6fb4
@ -46,6 +46,17 @@ require_once 'Zend/Date.php';
|
||||
* @subpackage fields-datetime
|
||||
*/
|
||||
class DateField extends TextField {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $default_config = array(
|
||||
'showcalendar' => false,
|
||||
'dmyfields' => false,
|
||||
'dmyseparator' => false,
|
||||
'dateformat' => false,
|
||||
'locale' => false
|
||||
);
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@ -81,6 +92,15 @@ class DateField extends TextField {
|
||||
if(!$this->getConfig('dateformat')) {
|
||||
$this->setConfig('dateformat', i18n::get_date_format());
|
||||
}
|
||||
|
||||
foreach (self::$default_config AS $defaultK => $defaultV) {
|
||||
if ($defaultV) {
|
||||
if ($defaultK=='locale')
|
||||
$this->locale = $defaultV;
|
||||
else
|
||||
$this->setConfig($defaultK, $defaultV);
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($name, $title, $value, $form, $rightTitle);
|
||||
}
|
||||
@ -320,6 +340,19 @@ JS;
|
||||
&& (!$val['day'] || Zend_Date::isDate($val['day'], 'dd', $this->locale))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $k
|
||||
* @param mixed $v
|
||||
* @return boolean
|
||||
*/
|
||||
static function set_default_config($k, $v) {
|
||||
if (array_key_exists($k,self::$default_config)) {
|
||||
self::$default_config[$k]=$v;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Boolean
|
||||
|
Loading…
x
Reference in New Issue
Block a user