mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
6227478f82
commit
498c075ece
@ -48,6 +48,7 @@ class DateField extends TextField {
|
||||
protected $config = array(
|
||||
'showcalendar' => false,
|
||||
'dmyfields' => false,
|
||||
'dmyseparator' => ' <span class="separator">/</span> ',
|
||||
'dateformat' => null,
|
||||
'datavalueformat' => 'yyyy-MM-dd',
|
||||
'min' => null,
|
||||
@ -101,13 +102,15 @@ class DateField extends TextField {
|
||||
$fieldYear->addExtraClass('year');
|
||||
$fieldYear->setMaxLength(4);
|
||||
|
||||
// TODO Locale specific ordering of fields
|
||||
$sep = ' <span class="separator">/</span> ';
|
||||
$html = $fieldDay->Field() .
|
||||
$sep .
|
||||
$fieldMonth->Field() .
|
||||
$sep .
|
||||
$fieldYear->Field();
|
||||
// order fields depending on format
|
||||
$sep = $this->getConfig('dmyseparator');
|
||||
$format = $this->getConfig('dateformat');
|
||||
$fields = array();
|
||||
$fields[stripos($format, 'd')] = $fieldDay->Field();
|
||||
$fields[stripos($format, 'm')] = $fieldMonth->Field();
|
||||
$fields[stripos($format, 'y')] = $fieldYear->Field();
|
||||
ksort($fields);
|
||||
$html = implode($sep, $fields);
|
||||
}
|
||||
// Default text input field
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user