(Retrofit from develop 5e1452f9) N°1580 Portal: Default image of image attributes not correctly displayed in object forms.

This commit is contained in:
Guillaume Lajarige
2018-07-26 16:22:15 +02:00
committed by Molkobain
parent 1973f7526e
commit 1cf36a5d01

View File

@@ -5835,6 +5835,32 @@ class AttributeImage extends AttributeBlob
{
return '\\Combodo\\iTop\\Form\\Field\\ImageField';
}
public function MakeFormField(DBObject $oObject, $oFormField = null)
{
if ($oFormField === null)
{
$sFormFieldClass = static::GetFormFieldClass();
$oFormField = new $sFormFieldClass($this->GetCode());
}
parent::MakeFormField($oObject, $oFormField);
// Generating urls
$value = $oObject->Get($this->GetCode());
if (is_object($value) && !$value->IsEmpty())
{
$oFormField->SetDownloadUrl($value->GetDownloadURL(get_class($oObject), $oObject->GetKey(), $this->GetCode()));
$oFormField->SetDisplayUrl($value->GetDisplayURL(get_class($oObject), $oObject->GetKey(), $this->GetCode()));
}
else
{
$oFormField->SetDownloadUrl($this->Get('default_image'));
$oFormField->SetDisplayUrl($this->Get('default_image'));
}
return $oFormField;
}
}
/**
* A stop watch is an ormStopWatch object, it is stored as several columns in the database