1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 11:14:12 +02:00

Fix issue processwire/processwire-issues#758 unable to select "17:10:02" time format in FieldtypeDatetime

This commit is contained in:
Ryan Cramer
2018-11-30 13:42:15 -05:00
parent 65b3edb761
commit 0442572885

View File

@@ -288,13 +288,13 @@ class FieldtypeDatetime extends FieldtypeText {
$f->addOption('', $this->_('None')); $f->addOption('', $this->_('None'));
$f->columnWidth = 50; $f->columnWidth = 50;
$date = strtotime('5:10:02 PM'); $date = strtotime('5:10:02 PM');
$found = false; $dateOutputFormat = $field->get('dateOutputFormat');
foreach($wdt->getTimeFormats() as $format) { foreach($wdt->getTimeFormats() as $format) {
$timeFormatted = $wdt->formatDate($date, $format); $timeFormatted = $wdt->formatDate($date, $format);
$f->addOption($format, $timeFormatted); $f->addOption($format, $timeFormatted);
if(!$found && strpos($field->get('dateOutputFormat'), $format) !== false) { if(strpos($dateOutputFormat, $format) !== false) {
$f->attr('value', $format); list(,$test) = explode($format, $dateOutputFormat);
$found = true; if(!strlen($test)) $f->attr('value', $format);
} }
} }
$f->attr('onchange', "$('#Inputfield_dateOutputFormat').val($('#Inputfield__dateOutputFormat').val() + ' ' + $(this).val());"); $f->attr('onchange', "$('#Inputfield_dateOutputFormat').val($('#Inputfield__dateOutputFormat').val() + ' ' + $(this).val());");