ENHANCEMENT Allow locale/dateformat specific reordering of day, month, year input fields in DateField (from r99361)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102860 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-14 04:39:36 +00:00
parent 6227478f82
commit 498c075ece

View File

@ -48,6 +48,7 @@ class DateField extends TextField {
protected $config = array( protected $config = array(
'showcalendar' => false, 'showcalendar' => false,
'dmyfields' => false, 'dmyfields' => false,
'dmyseparator' => '&nbsp;<span class="separator">/</span>&nbsp;',
'dateformat' => null, 'dateformat' => null,
'datavalueformat' => 'yyyy-MM-dd', 'datavalueformat' => 'yyyy-MM-dd',
'min' => null, 'min' => null,
@ -101,13 +102,15 @@ class DateField extends TextField {
$fieldYear->addExtraClass('year'); $fieldYear->addExtraClass('year');
$fieldYear->setMaxLength(4); $fieldYear->setMaxLength(4);
// TODO Locale specific ordering of fields // order fields depending on format
$sep = '&nbsp;<span class="separator">/</span>&nbsp;'; $sep = $this->getConfig('dmyseparator');
$html = $fieldDay->Field() . $format = $this->getConfig('dateformat');
$sep . $fields = array();
$fieldMonth->Field() . $fields[stripos($format, 'd')] = $fieldDay->Field();
$sep . $fields[stripos($format, 'm')] = $fieldMonth->Field();
$fieldYear->Field(); $fields[stripos($format, 'y')] = $fieldYear->Field();
ksort($fields);
$html = implode($sep, $fields);
} }
// Default text input field // Default text input field
else { else {