• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/UI/Input/Section.php
  • Класс: BitrixIblockUIInputSection
  • Вызов: Section::renderSelector
static function renderSelector(array $property, array|int|null $values, array $config): string
{
	$rowId = trim((string)($config['ROW_ID'] ?? ''));
	$fieldName = trim((string)($config['FIELD_NAME'] ?? ''));
	if ($fieldName === '')
	{
		return '';
	}

	if (($property['PROPERTY_TYPE'] ?? '') !== IblockPropertyTable::TYPE_SECTION)
	{
		return '';
	}

	$containerId =
		$rowId . ($rowId !== '' ? '_' : '')
		. $fieldName . '_container'
	;

	if (!is_array($values))
	{
		$values = !empty($values) ? [$values] : [];
	}
	TypeCollection::normalizeArrayValuesByInt($values, false);

	$multiple = ($property['MULTIPLE'] ?? 'N') === 'Y';

	$config['SEARCH_TITLE'] = (string)($config['SEARCH_TITLE'] ?? '');
	if ($config['SEARCH_TITLE'] === '')
	{
		$config['SEARCH_TITLE'] = Loc::getMessage('IBLOCK_UI_INPUT_SECTION_SELECTOR_SEARCH_TITLE');
	}
	$config['SEARCH_SUBTITLE'] = (string)($config['SEARCH_SUBTITLE'] ?? '');
	if ($config['SEARCH_SUBTITLE'] === '')
	{
		$config['SEARCH_SUBTITLE'] = Loc::getMessage('IBLOCK_UI_INPUT_SECTION_SELECTOR_SEARCH_SUBTITLE');
	}
	// TODO: replace entityId value to constant
	$config['ENTITY_ID'] = (string)($config['ENTITY_ID'] ?? 'iblock-property-section');

	$config = CUtil::PhpToJSObject(
		[
			'containerId' => $containerId,
			'fieldName' => $fieldName . ($multiple ? '[]' : ''),
			'multiple' => $multiple,
			'selectedItems' => $values,
			'iblockId' => (int)($property['LINK_IBLOCK_ID'] ?? 0),
			'userType' => (string)($property['USER_TYPE'] ?? ''),
			'entityId' => $config['ENTITY_ID'],
			'searchMessages' => [
				'title' => $config['SEARCH_TITLE'],
				'subtitle' => $config['SEARCH_SUBTITLE'],
			],
		],
		false,
		true,
		true
	);

	UIExtension::load('iblock.field-selector');

	return <<
HTML; }