From 75a0979eeed97a242e2e2591b30de7e115cb8582 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 6 Mar 2019 14:44:51 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02045=20Portal:=20Fix=20regression=20intr?= =?UTF-8?q?oduced=20with=20N=C2=B01980:=20New=20request=20with=202=20Reque?= =?UTF-8?q?st=20Templates=20does=20not=20display=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/forms/objectformmanager.class.inc.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php index 9587c14464..17561a2254 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php @@ -1100,10 +1100,30 @@ class ObjectFormManager extends FormManager } elseif ($oAttDef->GetEditClass() === 'CustomFields') { - if (!empty($value['template_data']) && !empty($value['user_data'])) + // We don't update attribute as ormCustomField comparaison is not working as excepted. + // When several templates available, "template_id" is not sent by the portal has it is a read-only select input + // therefore, the TemplateFieldsHandler::CompareValues() doesn't work. + // This use case works in the console as it always send all fields, even hidden and read-only. + + // Different templates + if( isset($value['template_id']) + && ($value['template_id'] != $value['current_template_id']) ) { $this->oObject->Set($sAttCode, $value); } + // Same template, different fields + elseif(isset($value['template_id'], $value['template_data']) + && ($value['template_id'] == $value['current_template_id']) + && ($value['template_data'] != $value['current_template_data']) ) + { + $this->oObject->Set($sAttCode, $value); + } + // Update of current values + elseif(isset($value['user_data'])) + { + $this->oObject->Set($sAttCode, $value); + } + // Else don't update! Otherwise we might loose current value } else {