From 1e48d945e2084a113fccd89c7dac6f17e303583d Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 15 Sep 2025 15:58:34 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06111=20-=20Display=20in=20read-only=20mo?= =?UTF-8?q?de=20a=20field=20in=20transition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index db70affe93..14d675e9e6 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -3266,13 +3266,16 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar if (array_key_exists($sAttCode, $aExpectedAttributes)) { $iExpectCode = $aExpectedAttributes[$sAttCode]; + $bIsPrompt=false; + $aAttrib = []; + $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); // Prompt for an attribute if // - the attribute must be changed or must be displayed to the user for confirmation // - or the field is mandatory and currently empty if (($iExpectCode & (OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) || (($iExpectCode & OPT_ATT_MANDATORY) && (false === $this->HasAValue($sAttCode)))) { + $bIsPrompt = true; $aArgs = array('this' => $this); - $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); // If the field is mandatory, set it to the only possible value if ((!$oAttDef->IsNullAllowed()) || ($iExpectCode & OPT_ATT_MANDATORY)) { if ($oAttDef->IsExternalKey()) { @@ -3283,8 +3286,7 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar $oRemoteObj = $oAllowedValues->Fetch(); $this->Set($sAttCode, $oRemoteObj->GetKey()); } - } else - { + } else { if ($oAttDef instanceof \AttributeCaseLog) { // Add JS files for display caselog // Dummy collapsible section created in order to get JS files @@ -3294,8 +3296,7 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar } } $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs); - if (is_array($aAllowedValues) && count($aAllowedValues) == 1) - { + if (is_array($aAllowedValues) && count($aAllowedValues) == 1) { $aValues = array_keys($aAllowedValues); $this->Set($sAttCode, $aValues[0]); } @@ -3316,15 +3317,22 @@ public function DisplayStimulusForm(WebPage $oPage, $sStimulus, $aPrefillFormPar $sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value, $sDisplayValue, $sInputId, '', $iExpectCode, $aArgs, true, $sInputType); + $aAttrib = array( + 'label' => ''.$oAttDef->GetLabel().'', + 'value' => "$sHTMLValue", + ); + } + if (($iExpectCode & OPT_ATT_READONLY) ){ + $bIsPrompt = true; + $sHTMLValue = $this->GetAsHTML($sAttCode); $aAttrib = array( 'label' => ''.$oAttDef->GetLabel().'', 'value' => "$sHTMLValue", ); - + } + if($bIsPrompt) { //add attrib for data-attribute // Prepare metadata attributes - $sAttCode = $oAttDef->GetCode(); - $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); $sAttDefClass = get_class($oAttDef); $sAttLabel = MetaModel::GetLabel($sClass, $sAttCode);