From fd9fe85ef3a64eebca3d2d757c64f85cab82f761 Mon Sep 17 00:00:00 2001 From: Guillaume Lajarige Date: Wed, 23 Aug 2017 14:39:58 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B0844=20Portal:=20ExternalField=20support?= =?UTF-8?q?=20in=20forms=20was=20not=20properly=20supporting=20external=20?= =?UTF-8?q?key=20as=20readonly.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:trunk[4873] --- core/attributedef.class.inc.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 50be39e98..b4fecdee0 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -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);