Documentation

SetEnumValues

CUserFieldEnum::SetEnumValues(
 int FIELD_ID,
array values
)

The method updates list values of user field. Non-static method.

Parameters

ParameterDescription
FIELD_IDUser field ID.
values
Array of specified values. List value IDs serve as array keys and key values define new list content.

If the key starts with "n" character, it is a new list value.

Key value serves as an array. This array has the following keys:
  • VALUE - value to print. If the string is empty, the value will be deleted from list;
  • DEF - by default flag (Y|N);
  • SORT - sorting;
  • XML_ID - external source ID. If not specified, it is calculated as md5 from VALUE.
  • DEL - if Y, this value will be deleted from list.
Values of keys specify a precise match for filtration.

See Also

Examples

<?
//User property is defined for users
// list type with ID of UF_GENDER.

//0. define field ID.
$arFields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields("USER");
if(array_key_exists("UF_GENDER", $arFields))
{
$FIELD_ID = $arFields["UF_GENDER"]["ID"];

//1. Add a drop-down list value: "do not know"

$obEnum = new CUserFieldEnum;
$obEnum->SetEnumValues($FIELD_ID, array(
"n0" => array(
"VALUE" => "do not remember",
),
));

//2. Change "do not know" to "do not remember"
$rsEnum = CUserFieldEnum::GetList(array(), array(
"VALUE" => "do not know",
));
if($arEnum = $rsEnum->Fetch())
{
$obEnum = new CUserFieldEnum;
$obEnum->SetEnumValues($FIELD_ID, array(
$arEnum["ID"] => array(
"VALUE" => "do not remember",
),
));
}

//3. delete the value "do not remember" from the list
$rsEnum = CUserFieldEnum::GetList(array(), array(
"VALUE" => "do not remember",
));
if($arEnum = $rsEnum->Fetch())
{
$obEnum = new CUserFieldEnum;
$obEnum->SetEnumValues($FIELD_ID, array(
$arEnum["ID"] => array(
"DEL" => "Y",
),
));
}

}
?>


© «Bitrix24», 2001-2022
Up