diff --git a/application/classes/modules/property/entity/ValueTypeDate.entity.class.php b/application/classes/modules/property/entity/ValueTypeDate.entity.class.php index ae06976c..d6d9dd02 100644 --- a/application/classes/modules/property/entity/ValueTypeDate.entity.class.php +++ b/application/classes/modules/property/entity/ValueTypeDate.entity.class.php @@ -36,8 +36,7 @@ class ModuleProperty_EntityValueTypeDate extends ModuleProperty_EntityValueType $oValue = $this->getValueObject(); $oProperty = $oValue->getProperty(); - return $oValue->getValueDate() ? date($oProperty->getParam('format_out'), - strtotime($oValue->getValueDate())) : ''; + return $oValue->getValueDate() ? $this->Viewer_GetDateFormat(strtotime($oValue->getValueDate()), $oProperty->getParam('format_out')) : ''; } public function isEmpty() @@ -48,18 +47,23 @@ class ModuleProperty_EntityValueTypeDate extends ModuleProperty_EntityValueType public function getValueForForm() { $oValue = $this->getValueObject(); - $oProperty = $oValue->getProperty(); - $sDate = $oValue->getValueDate(); $iTime = strtotime($sDate); // TODO: нужен конвертор формата дат вида Y в yyyy для учета $this->sFormatDateInput - return $sDate ? date('d.m.Y', $iTime) . ($oProperty->getParam('use_time') ? date(' H:i', $iTime) : '') : ''; + return $sDate ? date('d.m.Y', $iTime) : ''; + } + + public function getValueTimeForForm() + { + $oValue = $this->getValueObject(); + $sDate = $oValue->getValueDate(); + return $sDate ? date('H:i', strtotime($sDate)) : ''; } public function validate() { /** - * Данные поступают ввиде массива array( 'date'=>'..', 'time' => array( 'h' => '..', 'm' => '..' ) ) + * Данные поступают ввиде массива array( 'date'=>'..', 'time' => '..' ) */ $aValue = $this->getValueForValidate(); $oValueObject = $this->getValueObject(); @@ -69,7 +73,14 @@ class ModuleProperty_EntityValueTypeDate extends ModuleProperty_EntityValueType * Формируем формат для валидации даты * В инпуте дата идет в формате d.m.Y и плюс H:i если используется время */ - $sFormatValidate = $oProperty->getParam('use_time') ? $this->sFormatDateTimeInput : $this->sFormatDateInput; + if ($oProperty->getParam('use_time')) { + $sFormatValidate = $this->sFormatDateTimeInput; + if (isset($aValue['time'])) { + $this->setValueForValidateDate($this->getValueForValidateDate() . ' ' . $aValue['time']); + } + } else { + $sFormatValidate = $this->sFormatDateInput; + } $mRes = $this->validateStandart('date', array('format' => $sFormatValidate), 'value_for_validate_date'); if ($mRes === true) { diff --git a/application/frontend/components/property/input/property.date.tpl b/application/frontend/components/property/input/property.date.tpl index 0e40b708..8b19b47d 100644 --- a/application/frontend/components/property/input/property.date.tpl +++ b/application/frontend/components/property/input/property.date.tpl @@ -1,6 +1,19 @@ -{component 'field.date' +{$_mods=''} +{if $property->getParam('use_time')} + {$_mods='inline'} +{/if} +{component 'field.date' mods = $_mods name = "property[{$property->getId()}][date]" - inputClasses = "js-field-{$template}-default" + inputAttributes=[ "data-lsdate-format" => 'DD.MM.YYYY' ] + inputClasses = "js-field-date-default" value = $property->getValue()->getValueForForm() note = $property->getDescription() - label = $property->getTitle()} \ No newline at end of file + label = $property->getTitle()} + +{if $property->getParam('use_time')} + {component 'field.time' mods = $_mods + name = "property[{$property->getId()}][time]" + inputAttributes=[ "data-lstime-time-format" => 'H:i' ] + inputClasses = "js-field-time-default" + value = $property->getValue()->getValueTypeObject()->getValueTimeForForm()} +{/if} \ No newline at end of file diff --git a/framework b/framework index 1f3d5d8b..cf8fc7a3 160000 --- a/framework +++ b/framework @@ -1 +1 @@ -Subproject commit 1f3d5d8b03a5c55c05d163de38b708094ad19e25 +Subproject commit cf8fc7a3ea819e836e50fff4fc47f45e7d8931bd