CCrmViewHelper::PrepareFormTabFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmViewHelper
  4. PrepareFormTabFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_view_helper.php
  • Класс: \CCrmViewHelper
  • Вызов: CCrmViewHelper::PrepareFormTabFields
static function PrepareFormTabFields($tabID, &$arSrcFields, &$arFormOptions, $ignoredFieldIDs = array(), $arFieldOptions = array())
{
	$arTabFields = isset($arSrcFields[$tabID]) ? $arSrcFields[$tabID] : array();
	$arResult = array();

	$enableFormSettings = !(isset($arFormOptions['settings_disabled']) && $arFormOptions['settings_disabled'] === 'Y');
	if($enableFormSettings && isset($arFormOptions['tabs']) && !empty($arFormOptions['tabs']))
	{
		$arFields = array();
		foreach($arSrcFields as &$tabFields)
		{
			foreach($tabFields as &$field)
			{
				if($field['type'] === 'section')
				{
					continue;
				}

				$fieldID = isset($field['id']) ? $field['id'] : '';
				if($fieldID !== '')
				{
					$arFields[$fieldID] = $field;
				}
			}
			unset($tabFields);
		}
		unset($field);

		if(isset($arFormOptions['tabs']) && is_array($arFormOptions['tabs']))
		{
			foreach($arFormOptions['tabs'] as &$formTab)
			{
				if($formTab['id'] !== $tabID
					|| !isset($formTab['fields'])
					|| !is_array($formTab['fields']))
				{
					continue;
				}

				foreach($formTab['fields'] as &$formField)
				{
					if($formField['type'] === 'section')
					{
						continue;
					}

					$fieldID = isset($formField['id']) ? $formField['id'] : '';

					if(in_array($fieldID, $ignoredFieldIDs, true))
					{
						continue;
					}

					$field = isset($arFields[$fieldID]) ? $arFields[$fieldID] : null;
					if(!$field)
					{
						continue;
					}

					$item = array(
						'ID' => $fieldID,
						'TITLE' => isset($field['name']) ? $field['name'] : $fieldID,
						'VALUE' => isset($field['value']) ? $field['value'] : ''
					);

					if(isset($arFieldOptions[$fieldID]))
					{
						foreach($arFieldOptions[$fieldID] as $k => $v)
						{
							$item[$k] = $v;
						}
					}

					$arResult[] = &$item;
					unset($item);
				}
				unset($formField);
			}
			unset($formTab);
		}
	}
	else
	{
		foreach($arTabFields as &$field)
		{
			if($field['type'] === 'section')
			{
				continue;
			}

			$fieldID = isset($field['id']) ? $field['id'] : '';

			if(in_array($fieldID, $ignoredFieldIDs, true))
			{
				continue;
			}

			$item = array(
				'ID' => $fieldID,
				'TITLE' => isset($field['name']) ? $field['name'] : $fieldID,
				'VALUE' => isset($field['value']) ? $field['value'] : ''
			);

			if(isset($arFieldOptions[$fieldID]))
			{
				foreach($arFieldOptions[$fieldID] as $k => $v)
				{
					$item[$k] = $v;
				}
			}

			$arResult[] = &$item;
			unset($item);
		}
		unset($field);
	}
	return $arResult;
}

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