Просмотр исходного кода

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4873 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 7 лет назад
Родитель
Сommit
b9fd5c5060
1 измененных файлов с 19 добавлено и 3 удалено
  1. 19 3
      core/attributedef.class.inc.php

+ 19 - 3
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);