SetEnumValues
CUserFieldEnum::SetEnumValues( int FIELD_ID,
array values
)
The method updates list values of user field. Non-static method.
Parameters
Parameter | Description |
---|---|
FIELD_ID | User 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:
|
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-2024