CCrmUserType::normalizeBooleanValues

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmUserType
  4. normalizeBooleanValues
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_usertype.php
  • Класс: \CCrmUserType
  • Вызов: CCrmUserType::normalizeBooleanValues
public function normalizeBooleanValues(array $values): array
{
	$arUserFields = $this->GetAbstractFields();
	foreach($arUserFields as $FIELD_NAME => &$arUserField)
	{
		$isMultiple = $arUserField['MULTIPLE'] == 'Y';
		foreach ($values as $ID => $data)
		{
			if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'boolean')
			{
				$arVal = $values[$ID][$FIELD_NAME] ?? '';
				if (!is_array($arVal))
				{
					$arVal = [$arVal];
				}

				foreach ($arVal as $val)
				{
					$val = (string)$val;

					if ($val == '')
					{
						//Empty value is always 'N' (not default field value)
						$val = 'N';
					}

					if ($isMultiple)
					{
						$values[$ID][$FIELD_NAME][] = ($val == 1 || $val == 'Y') ? 'Y' : 'N';
					}
					else
					{
						$values[$ID][$FIELD_NAME] = ($val == 1 || $val == 'Y') ? 'Y' : 'N';
					}
				}
			}
		}
	}

	return $values;
}

Добавить комментарий