N°7145 - UI - Init Value DateTime and Date with Day Time (use OQL syntax for default value)

This commit is contained in:
Eric Espie
2025-01-09 10:49:35 +01:00
parent 0e8ddf990c
commit 886db5d6ad
3 changed files with 21 additions and 42 deletions

View File

@@ -6346,13 +6346,6 @@ class AttributeDateTime extends AttributeDBField
$oFormField = parent::MakeFormField($oObject, $oFormField);
// After call to the parent as it sets the current value
$oValue = $oObject->Get($this->GetCode());
if ($oValue === $this->GetNullValue()) {
$oValue = $this->GetDefaultValue($oObject);
}
$oFormField->SetCurrentValue($this->GetFormat()->Format($oValue));
return $oFormField;
}
@@ -6438,18 +6431,8 @@ class AttributeDateTime extends AttributeDBField
public function GetDefaultValue(DBObject $oHostObject = null)
{
$sDefaultValue = $this->Get('default_value');
if (!$this->IsNullAllowed() && utils::IsNotNullOrEmptyString($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();
}
if (utils::IsNotNullOrEmptyString($sDefaultValue)) {
$oDate = new DateTimeImmutable(Expression::FromOQL($sDefaultValue)->Evaluate([]));
return $oDate->format($this->GetInternalFormat());
}
return $this->GetNullValue();