mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°7145 - UI - Init Value DateTime and Date with Day Time
This commit is contained in:
@@ -6347,7 +6347,11 @@ class AttributeDateTime extends AttributeDBField
|
||||
$oFormField = parent::MakeFormField($oObject, $oFormField);
|
||||
|
||||
// After call to the parent as it sets the current value
|
||||
$oFormField->SetCurrentValue($this->GetFormat()->Format($oObject->Get($this->GetCode())));
|
||||
$oValue = $oObject->Get($this->GetCode());
|
||||
if ($oValue === $this->GetNullValue()) {
|
||||
$oValue = $this->GetDefaultValue($oObject);
|
||||
}
|
||||
$oFormField->SetCurrentValue($this->GetFormat()->Format($oValue));
|
||||
|
||||
return $oFormField;
|
||||
}
|
||||
@@ -6433,8 +6437,20 @@ class AttributeDateTime extends AttributeDBField
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
{
|
||||
if (!$this->IsNullAllowed()) {
|
||||
return date($this->GetInternalFormat());
|
||||
$sDefaultValue = $this->Get('default_value');
|
||||
if (!$this->IsNullAllowed() && $sDefaultValue !== '') {
|
||||
try {
|
||||
$oDate = new DateTimeImmutable($sDefaultValue);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
IssueLog::Error($e->getMessage(), null, [
|
||||
'class' => get_class($this),
|
||||
'name' => $this->GetCode(),
|
||||
'stack' => $e->getTraceAsString()]);
|
||||
return $this->GetNullValue();
|
||||
}
|
||||
|
||||
return $oDate->format($this->GetInternalFormat());
|
||||
}
|
||||
return $this->GetNullValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user