mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Allow locale/dateformat specific reordering of day, month, year input fields in DateField
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@99361 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c945e23c62
commit
d3a85844f7
@ -48,6 +48,7 @@ class DateField extends TextField {
|
|||||||
protected $config = array(
|
protected $config = array(
|
||||||
'showcalendar' => false,
|
'showcalendar' => false,
|
||||||
'dmyfields' => false,
|
'dmyfields' => false,
|
||||||
|
'dmyseparator' => ' <span class="separator">/</span> ',
|
||||||
'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 = ' <span class="separator">/</span> ';
|
$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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user