N°7577 - Issue with GetAttributeFlags when Attributes are set to HIDDEN

This commit is contained in:
Anne-Cath
2025-06-12 17:36:00 +02:00
parent f439490bfc
commit cc8c3d3bf1

View File

@@ -175,6 +175,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
*/ */
protected $sDisplayMode; protected $sDisplayMode;
protected $aFieldsMap; protected $aFieldsMap;
/*store posted values in order to be used in GetAttributeFlag*/
protected $aPostedValues = [];
/** /**
* If true, bypass IsActionAllowedOnAttribute when writing this object * If true, bypass IsActionAllowedOnAttribute when writing this object
@@ -3794,7 +3796,36 @@ HTML;
return $aWriteableAttList; return $aWriteableAttList;
} }
/** /**
* function to test if the posted value or fi not exists the existing value matches the expected value
* this is used to check the current value in GetAttributeFlag function (useful to manage dynamic readonly attributes)
* @param $sAttr
* @param $sValue
* @return bool
* @throws ArchivedObjectException
* @throws CoreException
*/
public function GetCurrentValue($sAttr)
{
if (array_key_exists($sAttr, $this->aPostedValues)) {
return $this->aPostedValues[$sAttr];
}
return $this->Get($sAttr);
}
/*
* This function checks if the value of the attribute has been modified in screen
* this is used to check if field has been modifed in GetAttributeFlag function (useful to manage dynamic readonly attributes)
*/
public function IsModifiedValue($sAttr)
{
if (array_key_exists($sAttr, $this->aPostedValues)) {
return $this->aPostedValues[$sAttr] == $this->Get($sAttr);
}
return false;
}
/**
* Compute the attribute flags depending on the object state * Compute the attribute flags depending on the object state
*/ */
public function GetFormAttributeFlags($sAttCode) public function GetFormAttributeFlags($sAttCode)
@@ -3986,6 +4017,7 @@ HTML;
$aErrors = []; $aErrors = [];
$aFinalValues = []; $aFinalValues = [];
$this->aPostedValues = $aValues; // Store the values for later use (e.g. in getAttributeFlag)
foreach ($this->GetWriteableAttList(array_keys($aValues), $aErrors, $aAttFlags) as $sAttCode => $oAttDef) { foreach ($this->GetWriteableAttList(array_keys($aValues), $aErrors, $aAttFlags) as $sAttCode => $oAttDef) {
$aFinalValues[$sAttCode] = $aValues[$sAttCode]; $aFinalValues[$sAttCode] = $aValues[$sAttCode];
} }