N°844 Portal: ExternalField support in forms was not properly supporting external key as readonly.

SVN:trunk[4873]
This commit is contained in:
Guillaume Lajarige
2017-08-23 14:39:58 +00:00
parent 7ed3e10d0f
commit fd9fe85ef3

View File

@@ -5085,15 +5085,31 @@ class AttributeExternalField extends AttributeDefinition
public function MakeFormField(DBObject $oObject, $oFormField = null)
{
if ($oFormField === null)
// Retrieving AttDef from the remote attribute
$oRemoteAttDef = $this->GetExtAttDef();
if ($oFormField === null)
{
// ExternalField's FormField are actually based on the FormField from the target attribute.
$oRemoteAttDef = $this->GetExtAttDef();
$sFormFieldClass = $oRemoteAttDef::GetFormFieldClass();
// Except for the AttributeExternalKey because we have no OQL and stuff
if($oRemoteAttDef instanceof AttributeExternalKey)
{
$sFormFieldClass = static::GetFormFieldClass();
}
else
{
$sFormFieldClass = $oRemoteAttDef::GetFormFieldClass();
}
$oFormField = new $sFormFieldClass($this->GetCode());
}
parent::MakeFormField($oObject, $oFormField);
// Manually setting for remote ExternalKey, otherwise, the id would be displayed.
if($oRemoteAttDef instanceof AttributeExternalKey)
{
$oFormField->SetCurrentValue($oObject->Get($this->GetCode().'_friendlyname'));
}
// Readonly field because we can't update external fields
$oFormField->SetReadOnly(true);