diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php
index 52c8a5676d..79a3efc82a 100644
--- a/application/cmdbabstract.class.inc.php
+++ b/application/cmdbabstract.class.inc.php
@@ -2034,7 +2034,7 @@ EOF
$oPage->add_dict_entry('Core:AttributeTagSet:placeholder');
/** @var \ormTagSet $value */
- $sJson = static::GetTagSetJsonForWidget($value, $sClass, $sAttCode);
+ $sJson = $oAttDef->GetJsonForWidget($value);
$sInputId = "attr_{$sFormPrefix}{$sAttCode}";
$sHTMLValue = "
{$sValidationSpan}{$sReloadSpan}";
$sScript = "$('#$sInputId').tagset_widget();";
@@ -2149,54 +2149,6 @@ EOF
return "";
}
- /**
- * @param \ormTagSet $oValue
- *
- * @param string $sClass
- * @param string $sAttCode
- *
- * @return string JSON to be used in the itop.tagset_widget JQuery widget
- * @throws \CoreException
- * @throws \CoreUnexpectedValue
- * @throws \MySQLException
- */
- private static function GetTagSetJsonForWidget($oValue, $sClass, $sAttCode)
- {
- $aJson = array();
-
- // possible_values
- $aTagSetObjectData = TagSetFieldData::GetAllowedValues($sClass, $sAttCode);
- $aTagSetKeyValData = array();
- foreach($aTagSetObjectData as $oTagSet)
- {
- $aTagSetKeyValData[] = [
- 'code' => $oTagSet->Get('code'),
- 'label' => $oTagSet->Get('label')
- ];
- }
- $aJson['possible_values'] = $aTagSetKeyValData;
-
- if (is_null($oValue))
- {
- $aJson['partial_values'] = array();
- $aJson['orig_value'] = array();
- }
- else
- {
- $aJson['partial_values'] = $oValue->GetModifiedTags();
- $aJson['orig_value'] = array_merge($oValue->GetValue(), $oValue->GetModifiedTags());
- }
- $aJson['added'] = array();
- $aJson['removed'] = array();
-
- /** @var \AttributeTagSet $oAttDef */
- $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
- $iMaxTags = $oAttDef->GetTagMaxNb();
- $aJson['max_tags_allowed'] = $iMaxTags;
-
- return json_encode($aJson);
- }
-
public function DisplayModifyForm(WebPage $oPage, $aExtraParams = array())
{
$sOwnershipToken = null;
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index 73a5a98a35..3ca36db19c 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -6715,6 +6715,47 @@ class AttributeTagSet extends AttributeDBFieldVoid
return array_merge(parent::ListExpectedParams(), array('is_null_allowed', 'tag_max_nb', 'tag_code_max_len'));
}
+ /**
+ * @param \ormTagSet $oValue
+ *
+ * @return string JSON to be used in the itop.tagset_widget JQuery widget
+ * @throws \CoreException
+ */
+ public function GetJsonForWidget($oValue)
+ {
+ $aJson = array();
+
+ // possible_values
+ $aTagSetObjectData = $this->GetAllowedValues();
+ $aTagSetKeyValData = array();
+ foreach($aTagSetObjectData as $sTagCode => $sTagLabel)
+ {
+ $aTagSetKeyValData[] = [
+ 'code' => $sTagCode,
+ 'label' => $sTagLabel,
+ ];
+ }
+ $aJson['possible_values'] = $aTagSetKeyValData;
+
+ if (is_null($oValue))
+ {
+ $aJson['partial_values'] = array();
+ $aJson['orig_value'] = array();
+ }
+ else
+ {
+ $aJson['partial_values'] = $oValue->GetModifiedTags();
+ $aJson['orig_value'] = array_merge($oValue->GetValue(), $oValue->GetModifiedTags());
+ }
+ $aJson['added'] = array();
+ $aJson['removed'] = array();
+
+ $iMaxTags = $this->GetTagMaxNb();
+ $aJson['max_tags_allowed'] = $iMaxTags;
+
+ return json_encode($aJson);
+ }
+
public function GetDefaultValue(DBObject $oHostObject = null)
{
return null;