• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/attribute/fieldattributemanager.php
  • Класс: Bitrix\Crm\Attribute\FieldAttributeManager
  • Вызов: FieldAttributeManager::prepareEditorFieldInfosWithAttributes
static function prepareEditorFieldInfosWithAttributes(array $attrConfigs, array &$fieldInfos): array
{
	$requiredByAttributeFieldNames = [];

	$isPhaseDependent = static::isPhaseDependent();
	for ($i = 0, $length = count($fieldInfos); $i < $length; $i++)
	{
		if (!$isPhaseDependent)
		{
			$fieldInfos[$i]['data']['isPhaseDependent'] = false;
		}

		$fieldName = $fieldInfos[$i]['name'];
		$attrConfigsValue = $attrConfigs[$fieldName] ?? null;
		if(!is_array($attrConfigsValue) || empty($attrConfigsValue))
		{
			continue;
		}

		$fieldInfos[$i]['data']['attrConfigs'] = $attrConfigs[$fieldName];

		$isRequiredByAttribute = false;
		$ready = false;
		$attrConfig = $attrConfigs[$fieldName];
		foreach ($attrConfig as $item)
		{
			if (
				is_array($item)
				&& isset($item['typeId'])
				&& $item['typeId'] === FieldAttributeType::REQUIRED
			)
			{
				if ($isPhaseDependent)
				{
					if (is_array($item['groups']))
					{
						foreach ($item['groups'] as $group)
						{
							if (is_array($group) && isset($group['phaseGroupTypeId'])
								&& $group['phaseGroupTypeId'] === FieldAttributePhaseGroupType::ALL)
							{
								$isRequiredByAttribute = true;
								$ready = true;
								break;
							}
						}
					}
				}
				else
				{
					$isRequiredByAttribute = true;
					$ready = true;
				}
				if ($ready)
				{
					break;
				}
			}
		}
		if ($isRequiredByAttribute)
		{
			$fieldInfos[$i]['data']['isRequiredByAttribute'] = true;
			$requiredByAttributeFieldNames[] = $fieldName;
		}
	}

	return $requiredByAttributeFieldNames;
}