1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 14:50:48 +03:00

fix property date type

This commit is contained in:
Mzhelskiy Maxim 2017-01-22 21:27:49 +07:00
parent 337b17b3d7
commit 8357c8e3f4
3 changed files with 35 additions and 11 deletions

View file

@ -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) {

View file

@ -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()}
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}

@ -1 +1 @@
Subproject commit 1f3d5d8b03a5c55c05d163de38b708094ad19e25
Subproject commit cf8fc7a3ea819e836e50fff4fc47f45e7d8931bd