\n";
$sHtml .= "
{$aAttrib['label']}
\n";
$sHtml .= "
\n";
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index f6175611f..f35d58336 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -1033,6 +1033,20 @@ abstract class AttributeDefinition
$oFormField->AddMetadata('attribute-code', $this->GetCode());
$oFormField->AddMetadata('attribute-type', get_class($this));
$oFormField->AddMetadata('attribute-label', utils::HtmlEntities($this->GetLabel()));
+ // - Attribute flags
+ $aPossibleAttFlags = MetaModel::EnumPossibleAttributeFlags();
+ foreach($aPossibleAttFlags as $sFlagCode => $iFlagValue)
+ {
+ // Note: Skip normal flag as we don't need it.
+ if($sFlagCode === 'normal')
+ {
+ continue;
+ }
+ $sFormattedFlagCode = str_ireplace('_', '-', $sFlagCode);
+ $sFormattedFlagValue = (($iFlags & $iFlagValue) === $iFlagValue) ? 'true' : 'false';
+ $oFormField->AddMetadata('attribute-flag-'.$sFormattedFlagCode, $sFormattedFlagValue);
+ }
+ // - Value raw
if ($this::IsScalar())
{
$oFormField->AddMetadata('value-raw', utils::HtmlEntities($oObject->Get($this->GetCode())));
diff --git a/core/metamodel.class.php b/core/metamodel.class.php
index 230d4df06..af0a52dee 100644
--- a/core/metamodel.class.php
+++ b/core/metamodel.class.php
@@ -2509,6 +2509,32 @@ abstract class MetaModel
return array();
}
+ /**
+ * Return an hash array of the possible attribute flags (code => value)
+ *
+ * Example:
+ * [
+ * "read_only" => OPT_ATT_READONLY,
+ * "mandatory" => OPT_ATT_MANDATORY,
+ * ...
+ * ]
+ *
+ * @return array
+ * @since 2.7.0
+ */
+ public static function EnumPossibleAttributeFlags()
+ {
+ return $aPossibleAttFlags = array(
+ 'normal' => OPT_ATT_NORMAL,
+ 'hidden' => OPT_ATT_HIDDEN,
+ 'read_only' => OPT_ATT_READONLY,
+ 'mandatory' => OPT_ATT_MANDATORY,
+ 'must_change' => OPT_ATT_MUSTCHANGE,
+ 'must_prompt' => OPT_ATT_MUSTPROMPT,
+ 'slave' => OPT_ATT_SLAVE
+ );
+ }
+
/**
* @param string $sClass
* @param string $sState
diff --git a/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php b/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php
index 2c9282414..486166d92 100644
--- a/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php
+++ b/datamodels/2.x/itop-portal-base/portal/src/Form/ObjectFormManager.php
@@ -944,6 +944,12 @@ class ObjectFormManager extends FormManager
$oField->SetDisplayMode($aFieldsExtraData[$sAttCode]['display_mode']);
}
+ // Overload (AttributeDefinition) flags metadata as they have been changed while building the form
+ $oField->AddMetadata('attribute-flag-hidden', $oField->GetHidden() ? 'true' : 'false');
+ $oField->AddMetadata('attribute-flag-read-only', $oField->GetReadOnly() ? 'true' : 'false');
+ $oField->AddMetadata('attribute-flag-mandatory', $oField->GetMandatory() ? 'true' : 'false');
+ $oField->AddMetadata('attribute-flag-must-change', $oField->GetMustChange() ? 'true' : 'false');
+
// Do not add hidden fields as they are of no use, if one is necessary because another depends on it, it will be automatically added.
// Note: We do this at the end because during the process an hidden field could have become writable if mandatory and empty for example.
if($oField->GetHidden() === false)