Skip to content

Commit bc9b130

Browse files
Add a renderValue() function to InputfieldDatetime
1 parent 0f395fa commit bc9b130

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

wire/modules/Fieldtype/FieldtypeDatetime.module

+2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ class FieldtypeDatetime extends FieldtypeText {
5151

5252
// Gregorian big-endian, starting with year (used in Asian countries, Hungary, Sweden, and US armed forces)
5353
'Y-m-d', // 2012-04-01 (ISO-8601)
54+
'Y/m/d', // 2012/04/01 (ISO-8601)
5455
'Y.n.j', // 2012.4.1 (common in China)
56+
'Y/n/j', // 2012/4/1
5557
'Y F j', // 2012 April 1
5658
'Y-M-j, l', // 2012-Apr-1, Monday
5759
'Y-M-j', // 2012-Apr-1

wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module

+12-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ class InputfieldDatetime extends Inputfield {
129129
return $out;
130130
}
131131

132+
/**
133+
* Render value for presentation, non-input
134+
*
135+
*/
136+
public function ___renderValue() {
137+
$value = $this->attr('value');
138+
if(!$value) return '';
139+
$format = trim($this->dateInputFormat . ' ' . $this->timeInputFormat);
140+
return FieldtypeDatetime::formatDate($value, trim($format));
141+
}
142+
132143
/**
133144
* Capture setting of the 'value' attribute and convert string dates to unix timestamp
134145
*
@@ -171,7 +182,7 @@ class InputfieldDatetime extends Inputfield {
171182
$f->attr('name', 'yearRange');
172183
$f->attr('value', $this->yearRange);
173184
$f->attr('size', 10);
174-
$f->label = "Date Picker Year Range";
185+
$f->label = $this->_('Date Picker Year Range');
175186
$f->description = $this->_('When the date picker is used, it has a selectable year range minus and plus 10 years from the current year. To extend or reduce that, specify the quantity of years before and after [current year] in this format: "-30:+20", which would show 30 years before now and 20 years after now.');
176187
$f->notes = $this->_('Default when no value present is "-10:+10" which shows a date picker year range 10 years before now, and 10 years after now.');
177188
$f->collapsed = Inputfield::collapsedBlank;

0 commit comments

Comments
 (0)